Put simply: too much gets by Starfleet, too much is absent, too much is simply forgotten or let slide for it to actually BE a full-time combat organization.
But that much is also true of the old Royal Navy. Due to severe limitations in technology, doctrine and zeitgeist, that force never was able to patrol the oceans, ensure the security of overseas assets, secure the trade routes or even protect immediate offshore interests. The ability to stop an invasion depended largely on other navies being equally inept and very, very timid, and thankfully was never really put to test.
As with most military organizations, the ability to implement some punitive measures every now and then, at least in theory, was sufficient raison d'etré for the Royal Navy, and sufficient for securing England's sovereignty as well. Starfleet isn't all that different from this...
Federation worlds undoubtedly DO have highly competent and specialized military forces for defending themselves from invaders, but in the age of automated/orbital defense platforms and ground-based weapons that can smash whole starships out of the sky, I doubt any of those military organizations have ever operated their own starships. Most fighting probably takes place on the ground anyway, and what little fighting DOES happen in space can usually be handled by Starfleet.
Makes sense - but is based solely on what is not
seen. We've never seen actual ground fights of the "pitched battle" type, fights that both sides would have prepared for and desired. We've seen mighty space fortresses in action, but never in the defense of UFP planets. And we've never seen "national" fighting forces represented by characters, sets or VFX - and the scant few dialogue references to such (ambiguous enough to possibly instead be references to Starfleet forces serving on that particular "national" theater) have involved space rather than surface assets.
For all we truly know
, no "national" forces exist whatsoever.