The Star Trek universe has two technologies which make this possible: Force fields and virtually unlimited energy thanks to mater/antimatter reactions focused through dilithium crystals, which is a really sciencey-sounding way of saying “magic.”
Wrap the whole moon in a force field powered by your unlimited energy. Then pump the force field full of air. Voila: people living freely on the moon.