There is no completely wrong answer in these sorts of questions because the reality is you're not going to know exactly what your choices are until the engine actually quits. And then you're not going to know whether or not your choice is right or wrong until you actually do it. Tons of planes have been put down very successfully on beaches over the years. Tons have also been put down in the breakers, just beyond the breakers, the back bays and the marshes. There really are no blanket wrong answers to this question. You always want to protect those on the ground first, yourself second and the plane third. But where you put the plane to accomplish those goals is going to change from moment to moment while flying.
And keep in mind as well that while you tend to find people on beaches, you also tend to find people in the water at beaches. The difference is, the people in the water are more difficult for you to see (you can only see their head) and they're less able to get out of your way if they see you coming, i.e. with the possible exception of Michael Phelps, people can usually run much faster than they can swim.