Your gas is incorporated into the planet during its formation and then gradually leaks out.
Your gas is a thermal decomposition product of planetary core / mantle materials, or a product of radioactive decay of these materials.
There is a theory that natural gas is produced deep inside the earth from materials sequestered there during the formation of the planet: the abiotic theory of fossil fuels. Microbes get involved with fossil fuels secondarily because it is tasty for them, but they do not form it in the first place.
The abyssal, abiotic theory of oil formation continues to receive
attention due to the work of retired Cornell astronomy professor
Thomas Gold... Gold’s theory of oil formation, which he expounded in a
book entitled The Deep Hot Biosphere, is that hydrogen and carbon,
under high temperatures and pressures found in the mantle during the
formation of the Earth, form hydrocarbon molecules which have
gradually leaked up to the surface through cracks in rocks. The
organic materials which are found in petroleum deposits are easily
explained by the metabolism of bacteria which have been found in
extreme environments similar to Earth’s mantle. These
hyperthermophiles, or bacteria which thrive in extreme environments,
have been found in hydrothermal vents, at the bottom of volcanoes, and
in places where scientists formerly believed life was not possible.
Methane is definitely in space and definitely could have been part of the original constituents of Earth. I could imagine water might do this too - celestial space water is bound up with minerals and winds up deep in the earth as the planet condenses from a cloud of dust. Over time the water breaks loose and begins to migrate, ultimately escaping through volcanoes as steam.
- Gases formed as breakdown products do occur without biological involvement. @Ash notes helium for one. Radon gas gets attention because it is a health hazard. It is generated by radioactive decay of materials in the crust.