I know that.
A gay friend of mine who was drafted and fought in Korea knew that. I salute all our soldiers - gay and straight - who fought to protect us.
BUT: if someone acted in a dishonorable way - they needed to be kicked out of the armed forces.
Those recruits at PI hadn't been caught committing sodomy - and thus violating the UCMJ - they simply declared themselves gay because they wanted out of the Marine Corps. An undesirable discharge is an administrative discharge for the convenience of the service; they were not being discharged as the result of a violation of the UCMJ.