Submarine is a water-tight boat which can travel under water like a ship. It is provided with water tanks. When the submarine is to dive, water is filled in water tanks and it is made heavier and the average density of submarine becomes greater than the density of seawater and it sinks.
Submarines first became a major factor in naval warfare during World War I (1914–18), when Germany employed them to destroy surface merchant vessels. In such attacks submarines used their primary weapon, a self-propelled underwater missile known as a torpedo.
Submarines sink by taking in ocean/sea water into large tanks. This weighs them down, allowing them to sink. They take in as much as they need to go as low as they want to. When they want to come back up, they pump out the water by pumping pressurized air into the tanks.