starfleet is NOT the military.
Of course it is.
some points to consider:
-captain jean-luc f***ing picard said himself starfleet was NOT military, pretty sure he knows what he is talking about,
Picard was also prone to to yammering about how humans were "more evolved now," and what a boatload of nonsense that
proved to be.
-court martial thing, well we're five years out from earth, i guess subspace mail the police a report (not)... i think it just makes sense for any organization flying around in deep space to have their own legal system
You might want to verify the definition of "martial
(Hint: "military" is a synonym
. "Soldierly" is another. "Court martial
" literally means "military court".)
While Starfleet may at this time or that perform scientific or exploratory or humanitarian/relief/rescue or diplomatic or civil engineering tasks, all
of those are secondary to (and, as necessity dictates, superseded by) its military function. Just like the military of today, or like the military of 48 years ago.