Answer:
Submarines have tanks called ballasts. To submerge, the ballasts are filled with water. This increases the submarine's mass which also increases its density, allowing it to sink.
To rise, compressed air is used to push the water out of the ballasts. This decreases the submarine's mass which also decreases its density, allowing it to rise.