Why did the plants and animals that make up fossil fuels not rot away?
They sank to the bottom of shallow oceans and were then compressed and cooked over millions of years.
When a tree falls in a forest and decomposes, we can look as it slowly turns to sawdust and ask - how could this thing have become oil so long ago?
The plants and animals that created fossil fuels died but they died in shallow seas where they then sank to the ocean floor. Over time, the plant and animal matter were crushed under millions of tons of sediment and other plant and animal matter. Crushed from above, heated from below from the Earth's mantle, the plant matter over time became hydrocarbons (i.e. fossil fuels).