How does carbon buried underground become coal oil , or natural gas?

1 plants using it for photosynthesis 2 animals using it as an energy source 3 exposure to heat and pressure over millions of years bacteria 4 breaking it down​