Dear student
Natural Gas: Organisms die, decay and get accumulated at the bottom of the earth. In course of time, sand and clay deposit over these decompositions. Over a period of millions of years, a thick layer gets formed compressing the organic material. Under conditions of high pressure and temperature, this organic material, over millions of years, got converted into petroleum. These organic materials are composed of nitrogen, hydrogen, carbon and other elements. Carbon and hydrogen in the form of methane is present in the gaseous form and present above the petroleum. So basically it is formed by the dead organic material , the more compressed from remains in the liquid form and called petroleum, and carbon ,hydrogen remains in the gaseous form above the petroleum called natural gas.
Regards