Technically it's prescription only. In reality if you ask a random group of men there's always someone with a bottle. Around military bases it's even worse because the military just throws the 800mg pills at everything.
I don't know what military life is like, but that hasn't been my experience as a civie. Most men I know wouldn't go to the doctor for something mild enough that it could be treated with ibuprofen.
Maybe there's just a huge black market Ibprofen ring. But more likely someone is prescribing them at low cost clinics and that's keeping the civilian supply going. Because it's absolutely the case where I am.