The moon also has water and it's a lot closer. Whatever goes wrong on Mars, it might be months or years before they receive help. Building the technology and experience with something a lot closer might be a better option before moving onto bigger things.
Thats the value of Mars. It forces whatever is built there to be sufficient and is largely a one way trip. A moon base will probably function more like a research station on Antarctica. New supplies will be shipped, people will transition back home every 4-12 months.
For health reasons you'll want to avoid people spending too much time on Lunar gravity. A similar issue exists on Mars, but causes the opposite result. Due to the time scales involved with sending someone to Mars and returning them, it will be a larger health risk for them to return to Earth than stay on Mars (3-9 month trip to Mars + mission time + 3-9 month trip back).
Think about the impact on culture as well. The sort of perspective you have working at a job site that you will only spend 4 months at is very different from the sort of perspective you have working at a home you expect to die in 30 years later. People that don't expect to come back to Earth may have kids on Mars. Most of the Martian kids will not be able to come back to Earth because of cost and health reasons.
A Mars research station is far more dangerous, more likely to fail, but if it succeeds is far more likely to result in long term habitation of an other planetary body.
There is nothing stopping you from building self-sufficient and secluded colonies on Earth as well. Svalbard has a no-visa-needed policy and is barely populated. If you can convince the Norwegian government to sell you land, you can build your colony there and will mostly be kept alone (compared to a colony in say Sahara which lies on a heavily populated continent).
The problem is that it is too to leave Svalbard. If something goes wrong, your Svalbard colony can call for help. On Mars if something goes wrong, help is at least 6 months away. On Svalbard if you aren't having fun anymore you can leave, on Mars it is likely a oneway trip unless you are a billionaire.