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.
I'm not sure where you're getting the "canonically not a military force" bit. There have been a number of wars in canonical history. Who did the fighting? Starfleet.
I think it's more accurate to say that the Federation of Planets wasn't militaristic, not that they didn't have a military or that Starfleet wasn't their naval equivalent.
And yeah, it's not conventional military fiction which usually revolves around actions during a war. But it's still military fiction in the sense that nearly all the characters are in the military and doing missions for the military. It just happens that the government running that military is at peace most of the time and uses its military for peaceful purposes when it's not actively at war.
> Gene Roddenberry was in the Navy
No, he wasn’t. He was a B-17 pilot in the Army Air Force.
It's a miracle he survived.
That bunch had the highest mortality rates of any unit (except maybe some of the Japanese units, who were basically suicidal), during the war.
He survived at least three plane crashes. He crashed on takeoff in a B-17. Two of his crew were killed. He later survived a crash as a passenger. He crashed again as a commercial pilot.
The 8th Air Force suffered heavy losses over Europe but I don't believe Roddenberry served there. He was in the Pacific and after his B-17 crash stayed in the mainland US.
Well shit I stand corrected then.