I wanted to chime in the the military part. This is not an age limit on positions to keep old people out, this is to weed out under performers at a time where the military has a glut of highly qualified volunteers.
So up or out means “if you’re passed over for promotion twice, you must suck and we don’t want you anymore.”
But I have seen old officers in the lower ranks because they were enlisted men, then warrant officers, then finally officers. They were far older than their peers, but still needed to tick the boxes and get promoted.
Ref: Military Officer