That's something I hadn't even thought of before... it could be the idea that Starfleet is a "combined service" is that it LITERALLY combines both military and non-military components into a single command structure and assign them to the same mission.
It would be like if you formed an exploration team made up of three marines, three astrophysicists, three State Department officials, three NASA astronauts with spacewalk experience, three computer engineers, three air force fighter pilots (to help run the space ship) and then put a guy from the Richmond Police Department in charge of the whole thing because he's really good at organizing group projects.
Starfleet doesn't seem to care about its legal status except that it knows that it hasn't been given the status of a military organization. It does clearly include a military ROLE for some of its members, either because they're trained for it or because they're a military contribution TO it (or both). This would explain why Kirk can say "I'm a soldier" and O'Brien can say "I'm an engineer" and Bones can say "I'm a doctor" without actually speaking for the totality of what their parent agency really is (the Enterprise, after all, is not an ambulance).