This may not be the best analogy but this is how I've always thought of it...
Starfleet officers go to the Academy, kind of like going to Westpoint or the Citadel here in the present-day US. O'Brien on the other hand, just signed up, went to boot camp and started working. He lacks the officer training and therefore will only be able to go so far in his career.
The irony is that he ends up teaching at the Academy, which he never attended.
It still doesn't make sense.
NCO's are not trained and qualified for "command", he would be "commanding" a large engineering staff, most likely including people who were trained and qualified to command.
Maybe he was able to get the job on DS9 because, at the time, it was a pretty crappy assignment. An NCO would never be able to be Chief Engineer on a ship like The Enterprise, but on a broke down Cardassian station in the middle of nowhere? Why not, no one else wants it.
Yep, it was a continuity flaw. But remember O'Brien start out as a bit character in "Encounter at Farpoint", I don't think the writers/producers at that point thought he would go onto be one of the main recurring characters in TNG let alone one of the lead characters in another Trek spin-off show.
Ultimatly, this is the real explanation.