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 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!!!!!

Coal and petroleum have been formed biomass which has been subjected to various biological and geological processes.coal is the remains of trees,ferns and other plants that lived millions of years ago .these were crushed into the earth ,perhaps by earthquake or volcanic eruptions.they were pressed down by layers of earth and rock .they slowly decayed into coal . oil and gas are the remains of millions of tiny plants and animals that lived in the sea .when they died ,their bodies sank to the sea bed and were covered by silt . bacteria attacked the dead remains turning into oil and gas under high pressures they were being subjected to.the silt was slowly compressed into rock.the oil and gas seeped into the porous of the rock and trapped like water in a sponge.