It's an irrelevant question in any historic context. Let me explain.
Human civilizations have had armies for thousands of years but a professional military that is an organ of a nation state whose purpose is to defend it from external threats is a historically new concept. To this day, it is not a universal thing. The People's Liberation Army in China is only colloqually called "The Chinese Military", but technically speaking, it's the military wing of the Chinese Communist Party. The United States and all Western countries have national defense forces, but if you go back to the early 20th century or 19th century, many of them did not. Even with respect to the United States, although the US Army claims lineage to 1775, "the military" as we think of it, at best, was a World War I creation (the so-called "National Army") and in many respects is a post-World War II creation in terms of how it actually works. If you go back further, there's all sorts of military or paramilitary forces around the world. Many were sworn to the person paying them (the king, the baron, the warlord). Some were professional, many were not. Perhaps most significantly, many rarely ventured a few hundred miles beyond their borders and were more about what we would call "internal security" (namely, the ruler's control of territory versus rivals). An "expeditionary force" is something only organized, resourced and experienced military forces could really do, be it if we're talking men on horseback or people on ships.
Point is what a "military" is has changed over a long period of time to mean very different things. And it likely will in the future in the well. Even within our own world, while right now the US Military comprises of 1.4 million uniformed servicemembers, advances in technology could make it so that in 70 years, that's really closer to 50,000 operators of semi-autonomous and autonomous defense platforms whose military capability far eclipses what 1.4 million people can do today.
So let's extrapolate that to the 24th century. 300-400 years hence, what a military organization is defined as likely will have been redefined several times as technology, politics and strategic requirements change. The entire designation would be irrelevant. Even within the military there are organizational designations like "Brigade", "Army", "Division", "Corps", "Regiment", "Battalion" that all have a historic basis to them, but whose relevance and scope has shifted over time. For example, go back 20 years, the US Army was chiefly organized around "Divisions", like it had been for much of the Cold War, and there were 10 of them and that number was meaningful, but since them, it's shifted (for modernization reasons) to be largely based around modular "Brigades", of which there are around 40 of. And those Brigades are attached to divisions for historic reasons (and Divisions to Armys and Corps) but they are designed to work with other divisions, and that is the relevant organizational unit.
I see it as entirely conceivable that with the shift to space, with the shift to exploration and a multi-species civilization with it's own history, that even the concept of "military" becomes irrelevant in the manner we think of it. Starfleet can engage in military action because it has the platforms and technology and experience to do so, and has some lineage to that order of being, but that's just really an emergent property of a greater set of capabilities.
I guess the short way of putting it is, just as it's wrong to apply modern military principles to the armies of the late Roman Republic, we shouldn't apply those principles to a future civilization whose needs, history and context is very distant from our own.
Starfleet isn't a military organization except in the extreme most general sense of "people with arms". It's simply, "Starfleet". It's on 23rd and 24th century thing that grew out of a 22nd century Earth based exploratory organization once it merged with the space arms of other Federation members. .