The necessary step for the formation of all fossil fuels is:
Heat and pressure build up on top of decaying matter.
While the burial of remains can occur in different environments (like swamps or oceans), the critical process that transforms organic matter into fossil fuels involves the buildup of heat and pressure over time.