How do plants get carbon? From air or soil? How is it different for aquatic plants and algae?
According to https://en.wikipedia.org/wiki/Soil_organic_matter soil has 3.3 times the size of the atmospheric pool of carbon.
From the air
Trees are autotrophs, which means that they create their own compounds from inorganic carbon. So, carbon comes from inorganic carbon. This carbon comes from $CO_2$ (carbon dioxide) that is present in the air. The process by which this carbon is transformed into organic matter is called photosynthesis. More specifically, the carbon get fixed through a chain of reaction called the Calvin cycle that are part of the photosynthetic process.
The great cycle of life
You'll note that while plants (and some other things) uses $CO_2$ to build their mass, animals (and some other things) exhale $CO_2$ when they breathe. In other words, respiration frees up carbon dioxide while photosynthesis fixes carbon dioxide into organic matter.
Then you may want to ask where does the carbon we exhale come from. From our food. If you eat a beef burger for example, you'll the carbon that was present in the cow. The beef got its carbon from the grass that she grazed on. The grass got its carbon from the air and there is carbon in the air because animals (and some other things) exhale carbon when we breathe. respiration and photosynthesis are two essential series of chemical reactions that explain the existence of this cycle.
The (very simplified) chemical equation for those two processes are
Introductory sources of information