How Can a Submarine Sink and Rise Again?
A submarine changes its average density by controlling the contents of large ballast tanks located around its pressure hull.
At the surface, the main ballast tanks contain air. The submarine displaces a volume of water that weighs more than the vessel, creating enough buoyant force to keep it afloat.
To dive, vents at the top of the tanks open. Seawater enters through openings below while the air escapes above. The added water increases the submarine’s average density and reduces its buoyancy.
Smaller trim tanks distribute water between the front and rear, allowing the crew to balance the vessel. Once underwater, diving planes act like wings. Water flowing across them produces forces that control depth and angle while the submarine moves forward.
To surface, compressed air is released into the main ballast tanks. The air forces seawater out, decreasing the vessel’s average density until buoyancy carries it upward.
A submarine normally maintains neutral buoyancy while cruising underwater. This means its weight is almost equal to the weight of the water it displaces. Small adjustments to tanks and control surfaces allow it to remain at a chosen depth without continually sinking or rising.
Source: Elements of Submarine Operation, United States Navy - Submarines and Neutral Buoyancy, United States Naval Undersea Museum

Pulteney Bridge, Bath, England
Source: Diego Delso