Tsunamis at sea occur when an earthquake abruptly raises or lowers the ocean floor (if the sea floor only shifts horizontally, this has little impact on the mass of water above it) and / or when a submarine landslide takes place.
The height and speed of tsunami waves depend on the parameters that triggered the quake and on the depth of the water. As a rule, waves propagated in deep water do not pose a danger and are recorded only by measurement buoys (if noticed at all). But as soon as they reach shallower waters, the mass of water towers high and can flood entire stretches of coastline, depending on the vertical displacement of the ground.
Since tsunami waves move more slowly than the P waves of an earthquake, endangered areas can be given several minutes' or even several hours' warning of an impending tsunami.