Much carbon is stored in the form of carbonate rocks, like limestone. When these rocks are subducted by tectonic activity into the mantle and metamorphized, the carbon they contain is released in the form of CO2, which can re-enter the atmosphere later through volcanic eruptions.
The lava in volcanoes is generated when e.g. crust material is molten during subduction of crust. This crust may contain CaCO3 etc and other carbonates. Unter high temperature, it will react with silica, alumina etc to form feldspar and carbon dioxide. Simplified: CaCO3 +SiO2 -> CaSiO3 + CO2.