Such a dangerous occurrence is prevented by active load management, avoiding high sea conditions for ships, and proper container/bulkhead design.
There are many types of loads that vessels carry that can shift, including containers, bulk cargo, liquids, and fluids that leak into bilges.
Most loads are in containers measuring 1/2, 1 or 2 TEUs, which are locked to each other and to the deck with twist-locks, and occasionally reinforced with steel cables.
Sometimes a honeycomb-like structure will be added to the cargo hold to prevent bulk from shifting enough to endanger the vessel and its crew.
[3] Similar to tanks, bilges have ridges built into them, and also tend to slope downward toward pockets, where water gathers for pumps.
A difficulty with bilges is that they do not have anti-slosh baffles like tanks, therefore water can move large distances and drastically shift the center of mass of the vessel.
[5] Cargo planes are designed to carry large loads long distances at high speed.