There are several different theories to explain how fossil fuels are formed. The most prevalent theory is that they form underground, under intense conditions. As plants, animals, and microorganisms decompose, they are gradually covered by layers of soil, sediment, and sometimes rock. Over millions of years, the organic matter is compressed.