Natural gas is the raw material. Gas as well as oil and coal, formed in the earth from organic substances of animal origin (i.e. deposits long-lived organisms) under the action of high pressures and temperatures.
Living organisms that died and descended to the sea floor, got in such conditions where they could not disintegrate as a result of oxidation (as on the seabed there is no air and oxygen), or destroyed by microbes (they just wasn't there). Deposits of these organisms formed silty sediments. As a result of geological movements these sediments penetrated to greater depths. There, under the influence of pressure and heat over millions of years passed, the process by which the contained carbon in the sediments moved into compounds called hydrocarbons. The name they received because their molecules consist of carbon and hydrogen. Hydrocarbons with large molecules (molecular) is a liquid substance, of them formed the oil. And low molecular weight hydrocarbons (which small molecules) are gases. They formed natural gas. But gas was formed under the influence of higher temperatures and pressures than oil.
That's why the oil is always available and natural gas.
Over time, these deposits have gone deep down - they were covered in layers of sedimentary rocks.
Natural gas is not a homogeneous substance. It consists of a mixture of gases. The main part of natural gas (98%) is methane gas. In addition to methane, in the composition of natural gas include ethane, propane, butane, as well as some non-hydrocarbonaceous substances - hydrogen, nitrogen, carbon dioxide, hydrogen sulfide.
Natural gas is in the ground at a depth of from 1 to several kilometers. In the terrestrial subsurface gas is in the microscopic voids - pores. The pores are interconnected microscopic channels - cracks. Through these channels the gas enters from the pores with high pressure in pores with a lower pressure.
Gas is extracted from the earth through wells. The gas exits from the subsurface through wells out due to the fact that the reservoir is under pressure significantly higher than atmospheric. Thus, the driving force of gas production with depth is the pressure difference between the reservoir and the collection system.