Building next to the ocean is fine. Japan has a
lot of experience in protecting their shorelines. The seawall that covers over 40% of their coastline is very impressive. However, as the 2011 tsunami demonstrated, all defenses eventually fail. While some blame lies with TEPCO avoiding recommendations to upgrade the seawall, it's hard to defend against the insane[1] power of over 4m of moving water.
This is why the real lesson is to build defenses in depth, with enough variety to protect against common mode failure. Fukushima Daini - only 12km away from Fukushima Daiichi - suffered similarly from the earthquake and tsunami, but a single surviving pump (and the skill and effort of the staff) was enough to prevent Daini from suffering the same fate as it's sister powerplant.
Good engineering asks questions like, "Are we safe when (not "if"!) the entire bank of backup generators fail?", or "Can a single event cause catastrophic failure?"
[1] https://www.youtube.com/watch?v=5IKIazZc-a8