Around 286 to 360 million years ago, during the carboniferous period, the world was covered in plants and organisms.
Over millions of years, these animals died and got buried underground beneath different minerals such as sand and clay
Over those millions of years, fossil fuels were created, with different combinations of time, pressure, organic matter, and temperature. Three major types of fossil fuels were formed, one of them being coal. Coal was formed with different types of plants and trees combined with pressure and heat.
The second major type of fossil fuel is oil, this was formed with smaller organisms like algae or zoo plankton combined with pressure that decomposed it.
The third major fossil fuel formed is natural gas, this was formed with the same process as oil, but there was more heat and pressure involved, which caused it decompose more and turn into natural gas,