Coal: about 350m years ago we didn't have trees because lignin had not evolved. Then we got lignin, and trees, and when trees died and fell they just stayed there because we didn't have fungus that could decompose them. Then (about 50m years later) fungus evolved that could decompose trees. All coal exists in that 300m to 350m old seam.
Life takes CO2, turns it into carbon, which is then released when those plants die and decompose.
Forests are a buffer, not a sink.