Because over the past fifty years Starfleet has been depicted as a military by every definition of the word with the exception of the five times where someone has said it isn't military. The first such reference doesn't come until twenty-three years after the franchise began, the next fourteen years after that, than the next three spread out over the course of the next fourteen.
Besides, sit down and watch TOS, it is very clear those writers thought they were writing about the military. The only reason Starfleet stopped being a military in Roddenberry's eyes was so he could discredit Harve Bennett and Nick Meyer. Also, by the time TNG came around he had also developed some weird hatred of the military, as evidenced by the infamous incident where Diane Carey wanted to dedicate her TNG novel to a friend in the Marines who had recently been killed in service, and Roddenberry lost his shit because "Star Trek isn't about military" and summarily banned her writing Trek novels, a ban which wasn't lifted until after he died.
And that's what it all comes down to. Judge Advocate General is a term that can only exist in the military, and the term court martial literally means military court. So Starfleet isn't military, but has a military court? That's like claiming the sport you play in which you skate on ice with a stick to whack a puck around isn't hockey.
No, Measure of a Man was to protest Starfleet orders regarding Data and his status as a citizen. What did happen under short notice was Picard serving as defense and Riker as the prosecution since the starbase in the episode was new and didn't have any legal staff assigned to it yet.
What the hell? His time with the Starfleet Infantry is part of Chief O'Brien's backstory and we actually do see them in two episodes of DS9.
Behind the scenes sources for the movie says those guys are Marines, and their uniforms are not the same as Kirk's. Note their "turtleneck" shirt is blue, as opposed to Kirk's white.
No one in the real world does that.
No, everything we've seen them do can and has been done by militaries.