This is one of the things that makes sci-fi stories set on Moon and Mars colonies more interesting than generic space opera with abundant/unexplained resourcing.
Unfortunately the Moon/Mars genre has been tainted by Heinlein’s “Moon is a Harsh Mistress” which recognized this question and solved it by making everyone a true libertarian who would rather nobly suffocate than steal air. When a criminal element shows up, it’s a racial stereotype shipped from Earth and the enlightened lunar dwellers simply kick him out and proceed with their zero-crime paradise of private property. Ridiculous book but understandably influential in its era.
This is precisely what happens in the Apple TV series “For All Mankind” an I think it’s a pretty realistic take on how future lunar and Martian settlements would work (either everyone cooperates or everyone is cooked)
Unfortunately the Moon/Mars genre has been tainted by Heinlein’s “Moon is a Harsh Mistress” which recognized this question and solved it by making everyone a true libertarian who would rather nobly suffocate than steal air. When a criminal element shows up, it’s a racial stereotype shipped from Earth and the enlightened lunar dwellers simply kick him out and proceed with their zero-crime paradise of private property. Ridiculous book but understandably influential in its era.