How do submarines sink if they have air inside?
The net force on the submarine depends on its average density, not on the density of one of its constituents. If the average density of the submarine is less than that of water, it will float upward in water. If the average density of the submarine is more than that of water, it will sink downward in water.
To determine the submarine’s average density, you need to divide its overall mass by its overall volume. While the submarine does contain air, a low-density material, it also contains steel, a high-density material. The submarine’s average density turns out to be very nearly that of water.
Fine adjustments to its density, made by pumping water in and out of ballast tanks, determines whether the submarines floats or sinks.