Space is dangerous
A space station is basically a really, really tiny planet. So imagine you lived on an asteroid big enough to house a few thousand people. What would you need to survive? What would you do if something went wrong? Now, compare that to what would happen if you lived on an earth-sized planet and something went wrong.
One of the biggest dangers in space is flying rocks. A tiny one can put a good sized hole in just about anything you can manufacture. Most machines that humans build don't work well with holes added to them willy-nilly. A space habitat needs passive or active micrometeorite defenses. If the active system fails, it's only a matter of time before the passive system (i.e., really thick hull) fails and you have a Very Bad Day(TM). A planet, on the other hand, only needs a passive defense, and it's pretty much always available: it's called "an atmosphere". If you lose that, you've screwed up something really big, and you have other problems to worry about.
Radiation is everywhere. If you're close to a star, the solar wind will bombard you with all kinds of high-energy particles that you really don't want going through your body. Again, you can have an active defense like a magnetic shield, or passive defense like a massive lead hull (very expensive). A habitable planet has two excellent passive defenses: that good ol' atmosphere, and a magnetosphere (well, not all planets have one, but you should modify it if it doesn't).
A space hab must have a closed ecosystem. But the stability of an ecosystem is a function of its size. Trying to make a closed ecosystem on the ISS would be insane, and probably impossible. Even if it worked, it would undoubtedly operate on a razor-thin margin. A giant hab with thousands of people would be better, but if some disease started ripping through your food supply, how long would the inhabitants last? What if resupply ships were too far away? Very easy to make the Donner Pass in Space.
An ecosystem covering millions of square miles will be thousands of times more stable than even a very large space hab. It would be able to host far more diversity in the food chain than is necessary to have a reliable supply. A space hab might be able to grow enough food to feed humans, but it is unlikely that it could grow an enjoyable diversity of food. The space available on even a small planet would explode the farming/animal husbandry options.
How do you get new goods on a space hab? You can recycle, you can mine nearby asteroids, or you can import raw or manufactured goods from planets. If there is any kind of disruption in the flow of materials or goods, the space hab could be crippled for new manufacturing (if it even has a meaningful manufacturing capability). This is especially relevant for warfare. Imagine trying to build fleet from space habs. If I were your enemy, I would know that all I need to do is disrupt your supply lines, and thereby cut off your ship-building capability entirely. I could destroy your navy before it is even built!
A planet can not only provide the raw materials for a space navy, it can provide a secure staging area for defensive weapons if you choose to attack my shipyards. I can build massive power generators in remote parts of my planet without putting my population at risk. If you build powerful generators near your space hab, they either need to be close enough to endanger your population, or far enough that I can attack them without dealing with your hab defenses. That limits the kinds of defensive weapons you can field.
In the event of a full-scale war, I would much rather use the natural deterrents of atmosphere and land to provide shelter than having to build every last shield in space. If my population relies on transported raw materials, my supply lines are a constant vulnerability. You could attack continuously, wearing down whatever defenses I have, until I run out of materials to rebuild. You have your choice of beam weapons, missiles, and kinetic kill vehicles to attack my space hab, which is presumably not very mobile, making it a sitting duck. And because volume is expensive in space (and makes me even more vulnerable), my people are crammed into a small area that is extremely trivial to target. Having to defend a space hab is a terrible military position.
On a planet, I can disperse my population, making any concentrated attack a waste of resources. I can tunnel underground, forcing you to either waste energy blasting through the surface, or landing for an invasion. Beam weapons will be attenuated by the atmosphere/magnetosphere for certain frequencies and beam types. Missiles will have to contend with potential counter-measures from all over the planet's surface, or in any number of orbits. Kinetic bombardment is made more favorable by the planet's gravity well, and may be the best attack. But if you can launch something big enough to kill my planet, then you can surely blow up any space hab you like with the same rock. If you are forced to invade, then I will have the advantage of native soil.
If I'm the leader of a space-faring civilization, I will choose to colonize planets over space habs every day of the week and twice on Sundays. I would only build habs in remote strategic locations where I want a presence but no suitable rock exists. Habs might be a nice vacation spot if you want exotic properties (controllable gravity, day/night, etc.), but not a sound basis for a large civilization. It is risky, costly, and foolish.