How does methane occur ?

In sewage gas, gobar gas, biogas where it is formed due to the bacterial decomposition of organic matter in the absence of air. In marshy lands where it is formed due to the bacterial decomposition of organic matter held under the stagnant water.