There is nothing to prevent anyone who wants to from colonizing the Moon or making habitats from asteroids.
It already says in the Outer Space Treaty that you own your habitat, so long as you occupy it. We need some kind of clarification of what happens with unoccupied habitats - at present it would seem that anyone can return an unoccupied habitat back to Earth and give it back to the nation that launched it. But so long as it remains occupied then it's yours, that much seems clear.
You can't own the Moon or any part of it or any celestial body - but then - there is nothing there worth owning for the most part. A vacuum covered landscape of rock. Your habitat would be the most valued asset of any settlement. And if you did any farming you'd do it in habitats also - no way you'd try to farm the unprotected lunar surface.
Also - I think most would say it's good that nobody can claim the Moon because otherwise you could get military bases on the Moon and who wants that? That's the main reason why territorial claims are ruled out. The US had ideas for a base on the Moon before the OST.
It's the same for many asteroids so far nothing to stop you from mining them and using them to make habitats to live in in space.
In the case of Mars then it gets much more complicated. The problem with colonizing Mars is that it may have habitats suitable for Earth life. Nobody knows for sure, but it's looking a bit more likely than it did say 10 years ago.
So that means that there is a chance that microbes you bring with you could irreversibly change the planet - bring life to it which was never there before.
It's kind of asymmetrical. Scientists want to study Mars without this nuisance of introduced Earth life. After all it would be the biggest anticlimax you can imagine in exobiology to go there and find only life you brought yourself - or to try to disentangle Earth from Mars life - bearing in mind that we have instruments that are so sensitive they can detect even a single amino acid in a sample. And we haven't sequenced more than a tiny fraction of all microbes. And Earth life could also potentially make Mars life extinct- that's easiest to see for the case where Mars life is some early form of life, e.g. maybe RNA only with no DNA yet. Imagine if there was something like that on Mars, but we introduce Earth life to the planet before we get a chance to study it?
Our understanding of evolution is very limited. We know only half of our history basically - in terms of gene complexity. Our understanding of how life got underway on Earth - it's just guesses really. And same for exoplanets, how likely it is, what processes happen early on - we have no idea.
So - to lose all that understanding just so that some colonists can land on Mars to try to colonize it - that's a big conflict between science and humans potentially.
The thing is - that Mars will still be there a million years from now. We don't have to try to colonize it now, if we decide to do it we can do it whenever we want to. But if we introduce Earth life to it, and it is able to flourish - that changes it irrevocably for all future time so for all those millions of years of our future civilization, or any other future civilizations, it is no longer possible for anyone to study Mars as it was before humans introduced Earth life to it.
We've made so many mistakes of that type on Earth, introduced life to places, then said "oops, now things are going extinct because we introduced rabbits to Australia" or whatever.
Many scientists would say we simply must not have a similar "oops" moment for Mars.
Mars and Europa are the two top priorities in our solar system to keep protected from Earth life. Most people are not that bothered about colonizing Europa - though there is a small group who want to do it.
But, for some reason, there are many who are dead keen on colonizing Mars.
If you look closely, it's really not that much of a place to live.
Nor is the Moon either, but on the Moon you are not in too much conflict with most of the science objectives, so long as you take reasonable care.
The main difference is that Mars is a connected system with dust storms that spread throughout the planet. It's atmosphere is a near vacuum, yet there is enough of it to spread fine dust, fine as cigarette smoke. And that dust is still able to carry microbe spores throughout Mars in principle, if there is somewhere they can survive.
Especially when you take account of the possibility of a hard landing, hard to see COSPAR approving a human mission to Mars.
So anyway - of the places close to Earth:
Those all have minimal planetary protection issues.
Though I think myself that before landing human missions on the very tiny Phobos and Deimos we need some experience of humans on the Moon. Because - I envision that a human settlement may well get surrounded by great piles of tons of debris, considering how many tons get discarded from the ISS each year to burn up in the atmosphere. No problem on the Moon, it is so large. But those tiny moons - not so sure.
That's just my personal view. You'd get permission to land on them probably. There are some planetary protection issues returning a sample from Phobos as it gets a lot of material from Mars so question of whether any of it was recent enough to contain viable life. Russia got permission to return a sample to Earth from Phobos but planned to do some planetary protection anyway just in case although not required by COSPAR.
Moon though is the obvious place to go for a first attempt. Even large caves which may give plenty of protection from cosmic radiation. May have large amounts of ice near the poles.
NOTE - I am not a lawyer, just describing the situation as an ordinary lay person who has read a bit around it and listened to a few talks by space lawyers.