A Submarine can float on water because the weight of the water displaced is equal to the weight of the craft. The upward force that the water has on the vessel is buoyant force. So..the key to controlling a submarine’s diving and resurfacing, is to control the buoyancy.
image/source: Science Channel
Modern submarines can dive up to 240 meters below the surface of the water. When the crew is ready to submerge, external ballast tanks that are normally filled with air, open to receive water. This makes the ship slightly negatively buoyant.
To keep the submarine level at any set depth, the submarine maintains a balance of air and water in the trim tanks so that its overall density is equal to the surrounding water neutral buoyancy. When the submarine reaches its cruising depth, the hydroplanes are leveled so that the submarine travels level through the water.
The density of a submarine then becomes greater than the water and it will submerge. There is a supply of compressed air on board that is used for both life support and to fill the ballast tanks.The speed of descent is additionally helped with a set of diving planes or “wings” on the top of the submarine. The angle of the wings is controlled thus influencing the angle of descent.