Odo was just kind of... there. He got the respect of Bajorans & Cardassians as an astute, impartial, and grumpy investigator. Like his arch-nemesis Quark, when one regime went out and a new one came in, they remained on the station. Quark was a civilian from an non-involved race, so it wasn't an issue. Odo was literally an unknown race, so it wasn't an issue for him. He seemed to wear a Bajoran uniform because DS9 was a Cardassian-built Bajoran-owned Starfleet-administered space station.
I don't think he was in the Bajoran militia, he just seemed sort of informally be deputized since he was doing the role for longer than the existence of the Bajoran militia/security apparatus. The way his comm channel interactions with the Bajoran security/military officials went felt kind of like the way Odo's comm channel interactions went with some of his contacts/allies he traded information with. He came off like an independent agent more than anything.
DS9 & Voyager each threw the standard command chain/range of ranks for a loop:
DS9:
- Starfleet Captain, Doctor, Science Officer, Chief Engineer...
- ... but said Chief Engineer is an enlisted man (Chief Petty Officer) not an officer.
- and the Doctor has a staff entirely of Bajorans.
- number two is a Bajoran militia officer, an ex-terrorist/freedom fighter serving a government that is brand new and still trying to figure out what end is up. She takes orders from Sisko but not explicitly from Starfleet, but she can order around everyone of Starfleet under her rank.
- Odo wears a Bajoran uniform, though he may not be wearing anything (mimic clothes), has a made-up rank of Constable, and commands some Bajoran security forces and Starfleet security forces (except for the Eddington era). He's station chief of security that seems only nominally beholden to the Bajoran government (he serves at their pleasure).
- Quark is a prominent merchant. A businessman/schemer who often ventures into gray market territory with the occasional black market foray. Rarely used, but kinda interesting when they do use him for various missions/expeditions.
- Engineering seemed more Starfleet than Bajoran, Command, the Ops had a fair number of Bajorans though somewhere on that station were a bunch of redshirts. Certainly not helmsmen.
- And said captain is the front of Starfleet's effort to bolster the provisional government and act as a buffer from exploitation or threats from other powers (and subtlely to smooth the path for their Federation membership), essentially a benevolent that is supposed to protect Bajor's interests for them, but this all gets complicated by him being an Emissary, a religious role.
VOY:
- Only people with any legit rank are Captain Janeway, Lt. Tuvok & Ensign Kim.
- Tom Paris was a criminal on special parole because of paternal connections and piloting skill. He was given a field commission that ended up lasting a lot longer than intended.
- Chakotay, Torres and all the Maquis (something like 25% of the crew, often a significant chunk of Engineering and yellow-redshirts) all had provisional ranks. Essentially being deputized. Chakotay & Torres had previous Starfleet training to some degree, most Maquis didn't.
- The Doctor had no rank at all and was only Chief Medical Officer because the entire medical team was killed. Wasn't even recognized as a sentient being instead of a holographic automaton until a year or so in.
- Kes was defacto nurse (and Paris a field medic) because of said lack of department.
- Neelix was basically just a civilian cook round-the-clock who saw the gravy train roll on by and was able to hop aboard. Sold himself as a scout, a goodwill ambassador (like a Sacagawea to a Lewis & Clark expedition) but ultimately his skill at preparing real food at least edible in contrast to a crew raised on replicators was his real role (not Tom's Diner but Neelix's diner. Duh da duh dah, duh da duh dah, duh da da duh da da). Some of his salvage expertise probably came in handy (though the crew's harvesting of minerals and foodstuffs was always mentioned in passing after Season 1), though he seemed too good natured to be a real hustler.
- Seven of Nine was like Odo. She was not Starfleet but a civilian onboard, no rank, but based on who she took orders from and who she could boss around, she was functionally a Lt. She was a department head of astrometrics. If she was in Starfleet, she would've worn blue. They essentially let her specialize in whatever interested her. In a way, she was a Neelix 2.0 as well, a guide to space through her Borg knowledge (eps where she chimed in about said races or phenomena).