Trees absorb carbon dioxide (CO₂) and convert it into hydrocarbon structures via photosynthesis. The carbon is stored in trunks and branches as the grow. On average, a tree will absorb about 30 kg of CO₂ a year (about 50% of a tree's dry mass is carbon!)
When trees die, carbon is released
After a tree dies, it will either: decompose or burn (naturally or specifically for energy). In both cases, almost all their stored CO₂ is released back into the atmosphere.