Most of the characters in Star Trek are members of the military. So of course, there's a chain of command and orders have to be followed.
The Federation of Planets wasn't a dictatorship.
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 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.