A military is an organization that has been designed to defend its governmental body from enemies both internal and external to the nation. A military can be made up of volunteers who have come together to serve, or it can be a conscripted fighting force that is a requirement of all citizens of a government.
Starfleet of the United Federation of Planets is an example of a military unit defending a large governmental body; whereas the Bajoran Militia is an example of a unit defending a single government, in this case the Republic of Bajor.