It isn't really military fiction in the sense that it intends to accurately portray or extrapolate on military culture and tactics. Gene Roddenberry was (apparently not) in the Navy, and TOS is mostly The American Cold War In Space (with the Enterprise as a Submarine In Space - looking at you "Balance of Terror" - but it's pretty clear watching TNG onwards that the "military" aspect of the whole thing, like the "post scarcity communism" is window dressing. It's just a necessary part of the franchise.
And they aren't even really members of the military. Starfleet is canonically not a military force, its purpose is exploration, science and diplomacy. It just happens to have a military chain of command, and ships with military designations bristling with planet-cracking weapons. That get into battles and fight wars a lot.
It isn't really military fiction in the sense that it intends to accurately portray or extrapolate on military culture and tactics. Gene Roddenberry was (apparently not) in the Navy, and TOS is mostly The American Cold War In Space (with the Enterprise as a Submarine In Space - looking at you "Balance of Terror" - but it's pretty clear watching TNG onwards that the "military" aspect of the whole thing, like the "post scarcity communism" is window dressing. It's just a necessary part of the franchise.
And they aren't even really members of the military. Starfleet is canonically not a military force, its purpose is exploration, science and diplomacy. It just happens to have a military chain of command, and ships with military designations bristling with planet-cracking weapons. That get into battles and fight wars a lot.