Methane, CH4, is formed by an endothermic reaction, so it absorbs heat. Whenever a substance is formed by an endothermic reaction, it contains more energy than the parts of it alone (C+2H2), which means it is more unstable than C and H2. Whenever there is an exothermic reaction, energy is released, and the products have less energy, so they are more stable. You know that when you burn hydrocarbons (fuel), you get fire. It would take as much energy released in that fire to make the original hydrocarbons, which would absorb that energy. So the making of hydrocarbons can't be spontaneous, but in gaseous planets like Jupiter and all them, there is immense heat and pressure, so if they had hydrogen and carbon, its very easy to make it. If you want some methane (sorry to be gross), take a balloon and hold it up to a cow's anus.
Sorry if that was confusing