coal is formed by the process of carbonisation.
about 300 million years ago the earth had dense forests in low lying wtland areas.due to natural processes, like flooding these forests got buried under the soil.as more soil deposited over them, they were compressed, the temerature also rose as they sank deeper and deeper. under high pressure and high temperature, dead plants got slowly converted to coal as coal contains mainly carbon, the slow process of conversion of dead vegetation into coal is called carbonisation. since, it was formed from the remains of vegetation, coal is called a fossil fuel.
Petroleum was formed from organisms living int he sea. as these dead organisms died, their bodies settled at the bottom of the sea and got converted with layers of sand and clay. over millions of years, absence of air, high temperature and hish pressure transformed the dead organisms into petroleum and natural gas.
Hope it is helpful!!!!!