Sinking or Floating in Water
Ships float in water even though many are made of steel which is considerably more dense than water, because the AVERAGE density of the ship is less than water. The volume of a ship include in tinside, much of which is air. This is cionserably less dense than water, so the overal density of the ship is less than water.
On the other hand, the Titanic sank. When the Titanic struck an iceberg, it rapidly started filly with water and the average density increased rapidly. When the average density of the Titanic exceeded that of water, the ship sank.
There are some objects though, that can either sink or float in water, as desired. Fish and submarines have the two aids of propulsion and the ability to vary their own buoyancy. A submarine can drive itself forward and steer up or down with rudders. A fish can swim forwards and steer with it's fins. Both submarine and fish can increase their buoyancy by pumping gas into internal cavities. Gas is less dense than water so overall density of submarine or fish decrease and submarine or fish will tend to rise. Conversely, they can make themselves sink by expelling gas.
There is one other method of changing buoyancy, illustrated by the cartesian diver. This consists of a thin hollow glass figure, or tube, heavier at the bottom, with an open tail. Being full of air, it normally floats. By putting the diver inside a bottle of water and pressing down on a lid of some sort, the pressure inside the bottle increases. The air inside the diver increases and the air is compresses, making the diver denser than water, so it sinks.