A tree can gain tons of wood in its life, yet the soil it grows in hardly shrinks. Most of that wood is carbon the leaves take from the air as carbon dioxide, joined with parts of water, using the energy of sunlight. That job is called photosynthesis.
The leaf is cut open and drawn far bigger than real, and its parts are not to scale. Air bits, water and sugar are drawn as big balls so you can see them; real ones are far too small to see, and there are countless of them. The soil dropping a little is exaggerated: in the classic experiment it lost about 2 ounces out of 200 pounds. Real photosynthesis is many small steps inside a chloroplast, shown here as one flash. The oxygen that leaves comes from the water, not the carbon dioxide. Real leaves carry water up and sugar down in two separate sets of tubes. Young green stems make a little sugar too, but trunks and roots mostly cannot. The classic experiment: a 5 pound willow shoot grew to about 169 pounds in five years while the soil lost about 2 ounces.
Arizona State University: Where does a plant's mass come from
Michigan State University Extension: Where do trees get their mass
CSB/SJU: van Helmont's willow experiment
OpenStax (Rice University): Overview of photosynthesis
OpenStax: The light-dependent reactions
NASA: STEMonstrations, Photosynthesis