I'm not quite sure your analogy follows, because states have many more distinguishing features that run far deeper than things like rank structures, but here goes:
It would be perfectly reasonable to say that one of the fundamental traits of a state has historically been a tendency to engage in racism and sexism. Female Americans and Americans of African descent, for instance, were traditionally discriminated against, often in very violent ways, in the United States, for instance. Canadians of French descent have suffered a history of oppression, Israelis of Arab descent face persecution in Israel.... Etc.
I would submit that this argument is part of a broader pattern of state-based discrimination, not just on race or sex but ethnicity, religion, dis/ability, sexual orientation, etc. So the question as I see it is: is discrimination an inherent part of the nation-state as an apparatus, or merely a result that so far all nation-states have been populated and run by discriminatory people? Unfortunately, I believe discrimination
is inherent in the idea of the nation-state, which at it's most basic level is a means of making divisions: these are 'our' people, those are not. We're all human, but the nation-state system says that some of us are Canadian, not Mexican; Indian, not Pakistani; Chinese, not Japanese. The Federation, whether it wants to or not, makes the same distinction; so, we're all sentients, but some of us are Federation, not Carnelian Regency, etc.
And yet, no one disputes the fact that states continue to exist in the world of Star Trek. The United Federation of Planets, indeed, possesses all of the traits of a state. And yet, so far as we know, the Federation is extremely nondiscriminatory -- even creatures initially believed to have been nonsentient are, upon the discovery of their sentience, welcomed into the government and made equal partners on all levels of society. Why? Because in the world of Star Trek, the behavior of the state has changed. It is still a state, but it is no longer a state that does those bad things that states used to do.
I don't agree. Specific internal discrimination has been a feature of almost all states I can think of, but it's also a process that is in constant flux because (I would hope) human history demonstrates progress from intense to lesser discrimination. So we used to discriminate strongly against people of certain races, certain faiths, gender, etc., until that became passé as society gradually learnt its lesseons... but then it was replaced, or it became more evident that will still discriminate against other faiths (or lack thereof), non-standard sexualities, the differently abled, ageism... tomorrow, it'll be something else that will be the 'big issue', transsexuals or multiple marriages or something we can't even predict yet. What is common to states is not the specific type of discrimination practiced, but that is exists, and is gradually (progressively) shifting from sub-class to sub-class.
Now, what about the Federation? It is true that the Federation is remarkably non-discriminatory. We saw it conquer anti-alien sentiment in ENT's era, then (because the military is, by its nature, a more conversative animal, slower to change, than society broadly) that same prejudice is defeated within the militarized Starfleet of Kirk's time to become more-or-less a non-issue by the 24th century. So the Federation (and its precedant society) evinces the same kind of 'progression' of non-discrimination. It wants to be non-discriminatory, but because you can't always predict where the next issue will arise, it is difficult to always do so: we saw prejudice against artificial lifeforms raised, challenged and defeated on TNG with Data and the exocomps; we saw, in VOY, the prejudice against holographic lifeforms (usign EMH Mark Is as slave labour in mining!) and the beginning of the challenges to that form of discrimination, with the hope that soon sentient holograms will achieve full rights as Federation citizens. The process of recognizing and defeating discrimination is faster in the Federation, because it's at the end of a long process of evolving rights, because it's an enlightened, rational, well-meaning and just gosh-darn better society... but it's still there. Too a far lesser degree, absolutely, but it's not gone away, in large part because it isn't always self-evident to recognize it as it's happening.
Are those traits inherent to the military, or are they the products of the societies in which those militaries exist? (...) Cannot the same be true of the military and of Starfleet? Because nothing in that list of traits you associate with the military is actually necessary for something to be a military.
So you say. I think there comes a point where a correlation becomes so overwhelming that you have to start wondering if there might not also be a causation there. 'Military' is a mindset created by a designated function--fighting the 'enemy'--which displays martial culture, and those 'traits', I would argue, stem from that mindset. Starfleet does not display that culture; it has miltiary trappings, but not the mindset.
ETA:
So the solider (and what else is he?) with the tubes of ketecal white around his neck, what is he?
I'm not sure I understand the question. The Dominion has a slave-army, and the Jem'Hadar do very much evince a martial culture... but how does that reflect on the Federation and Starfleet?
Fictitiously yours, Trent Roman