At the heart of both the carbon and nitrogen cycles are microorganisms such as bacteria. These key nutrients pass from plants to animals through ingestion and digestion (eating!) in a very straightforward way, but what happens after those organisms die is a far more interesting tale.
Plants take up atmospheric CO2 to photosynthesise: the carbon in CO2 is transferred to the carbon in glucose.
This carbon in glucose is either respired by the plant itself and released as CO2 back into the atmosphere, or is passed on to animals eating the plants. Here, it either gets released back as CO2 in respiration or becomes manure.
But eventually, all the carbon not quickly released back into the atmosphere as CO2 will end up in the ground, for microorganisms to decompose.
Saprobiotic* bacteria can assimilate organic waste (all of which is made of carbon) and use it for their own respiratory needs. This in turn produces CO2 or methane gas, depending on species. Both gases get released into the atmosphere from where plants take CO2 up again for photosynthesis, restarting the cycle.
*Externally digesting… kinda like someone chewing your food for you.