The USAF was an outgrowth of the U.S. Army originally. The U.S. Army Air Forces up through World War Two. This IIRC was largely due to the original role of aircraft in performing recon for the army and roles like that about 100 years ago.
Somebody has to clean the toilets. His survival on a TNG-era ship would be in doubt unless someone has a still somewhere.
That's 'cuz O'Brien was a Chief by then, which is the equivalent of a Non-Commissioned officer for the Marines and Army But yeah, someone mentioned that most of the things that the Ensigns of Star Trek do is stuff that enlisted folks would do, such as piloting the ship. If you ever go up on the bridge of a Navy ship, you'll have an Officer of the Deck that's overall in charge when the CO's not around, a Junior OOD and a conning officer all the rest of the shit's done by enlisted. You watch Star Trek and you got officers going on away missions and shooting down the bad guys and shit. Nope!