When the air tanks are full of air the submarine will float - usually submarines are designed to float on the surface quite low in the water (only a little freeboard). When the submarine dives (submerges) water is let into the tanks; to surface again air is blown into them. This air must be stored inside the submarine in compressed air tanks. If the submarine submerges with its compressed air tanks empty it will not be able to surface again, so once it has surfaced the very first thing it must do is to start refilling them.
Water is incompressible - this means that, unlike air, when you increase the pressure you do not change the volume. This in turn means that although the pressure increases as you go deeper under the sea the density of the water does not change, and this means that if the submarine's buoyancy is less than its weight at one depth it will also be less than its weight at any other depth, and so, unless other forces are involved, when water is let into the air tanks the submarine will sink right to the bottom of the sea no matter how deep it is.
A submarine is kept level at any depth by maintaining a balance between the air and water. The submarine's density must be equal to the surrounding water so that it is buoyed at that level. To bring a submarine back to the surface, air is used to force the water out of the tanks. As the water is removed, the submarine's density decreases and the submarine rises to the surface.
Spaceships are built like submarines in reverse. Instead of keeping water pressure out of the vehicle, they keep air pressure inside the vehicle. So the structural engineering is completely