Starfleet IS the standing military of the United Federation of Planets, regardless of it's other duties and activities, and regardless if members maintain their own defense forces or civil defense initiatives/militias.
Its
primary purpose is not defense. In the future war is more or less a relic of the past. Human beings and many aliens set aside violence to live peaceful and prosperous lives of exploration and understanding. Starfleet (which one can imagine growing out of NASA, not the Space Force/MACOs) is a scientific and exploratory organization, not a military one – explicitly. Defense is secondary, a burden. When you go out to the bar to meet new people, you're there to have a good time. If you have to deal with bad behavior, did you go out there to be security guard? Are you one? Or did you simply exercise other parts of yourself? This is how I see Starfleet. Indeed, this is how I see our
actual future, if we're so lucky to keep it.
The problem with Star Trek is that it's a TV show that needs high drama every week, and usually drama that appeals to boys. When ratings began to drop, VOY brought in sex (Seven), and DS9 brought in violence (the Dominion War...the Klingon War...the Tzenkethi War...the ever present specter of past and future Cardassian Wars). That's all swell and all if you don't take it too seriously. Like the number of scantily clad women Kirk ran into in TOS, how the starboard power coupling seemed to blow every week on TNG, or the number of times O'Brien was really put through the wringer on DS9.
In the real world, space is mostly empty and lifeless, and aliens are more likely to be a million years ahead of us (Organians, Vorlons, 2001) or behind us (proto-Klingonoids). We'll likely have few interactions with such beings and the burden will be on us to live with ourselves. This being the case, I think families on starships makes sense, and frankly I pity the idea of militaries in space at all. It's a terrestrial concept I hope dwindles with each passing decade, century.