Aquatic plants are able to absorb the carbon dioxide (CO2) they need to make food directly from the water around them through their leaves, just as land plants obtain carbon dioxide from the air. The water provides the nutrients necessary for an aquatic plant to "breathe" underwater.
Plants produce food from a chemical process called photosynthesis, which combines carbon dioxide, water, and sunlight to produce glucose. Aquatic plants are able to absorb the carbon dioxide that has been dissolved into the water they live in. This carbon dioxide can originate from the atmosphere or from animals and bacteria via respiration. This process of carbon dioxide entering the water happens naturally as part of the atmospheric balance.
Underwater plants also have specially designed stems to allow for the gas to be exchanged between the leaves where it is absorbed from the water. In addition to carrying the carbon dioxide, the water itself is absorbed by the plant. The other vital part of plant nutrition, sunlight, can pass through water. Using sunlight as an energy source, aquatic plants are able to combine the water around them with the carbon dioxide that is absorbed through the leaves to create food in the form of glucose.