Until they do due to a mistake, ships do not sink, not even the large and heavy ones. Now and then, textbooks say this is because of dissimilar density. Though not wrong, it is also not a fundamental reason. While ships may sink to the bottom of the ocean thanks to gravity, they also float thanks to gravity.
When a vessel is launched in the water, it will always sink a little bit under the surface, until it stops sinking, preferably at a safe distance from where humans tend to loiter. And since, in this universe, water and the submerged part of a hull cannot occupy the same space at the same time, the submerged volume equals the volume of displaced water. This causes, however small, to raise the surface of the water. Due to the sheer size of most bodies of water, that rise is unnoticeable.
In spite of this usually insignificant level increase, gravity is still ‘pulling down’ every cubic part of the raised water, which is then, through pressure, also pushing on the ship. The force of the weight of the displaced water is equal to the force exerted upwards on the bottom of the ship. This is called Archimedes’ principle.
In other words, while the ship exerts a force on the water due to gravity, the water around the ship exerts a force back at it, through pressure, due to gravity. Notice how it is working against itself, as it were. But, as long as the force of the weight of the water is equal to the force of the weight of the ship, it’s fine. Yes, water pressure also pushes on all submerged sides of the object, but they cancel each other out as they work against each other with equal strength so we can leave them out of the equation.
The trick, of course, is to design the shape of a hull in such a way that its submerged volume displaces a volume of water weighing as much as the ship’s weight. These choices influence the ratio between its volume and its mass. And the latter is why referrals to density are made—often accompanied by a nifty display of algebra. Though not fundamental, density is a useful property to work with on Earth, such as when explaining why oil floats on water.
Until you are not on Earth but on the International Space Station, for instance. Do have a look at what happens when the lower-density oil and higher-density water are put together when gravity is out of the mix.
Of course, air pressure also exerts a force on the ship. However, it does so on the water surface too. As we also wanted to keep things simple, we thus did not take this any further into consideration.