I never knew until now that nearly all coal was produced over a relatively short geological time from 360 to 300 million years ago. 360 million years ago existing fungi and bacteria could decompose all plants of that time, returning the nutrients back to the soil. The nutrient cycle. Eventually evolution produced a molecule called lignin in plants. Lignin enabled woody plants to develop and quickly trees became a dominant species quickly covering the earth. But, when the trees died there were no existing fungi or bacteria that could decompose the new plants with the lignin molecules. Consequently when trees died they did not decompose and simply piled up and got squished over the eons eventually become fossilized then becoming coal. After 60 million years a bacteria that can digest lignin molecules eventually evolves, spreads rapidly due to the abundant food source, and coal production ends.
source of info was a you tube video. If you want to see it search YouTube for “Why almost all coal was made at the same time” By Steve Mould (ironically)