The rights are not necessarily waived but are subordinate to military regulations (UCMJ) in order to promote "good order and discipline". Discipline is a critical factor in the effectiveness of military units. The courts have typically trusted rulings of military courts since civilian courts are not necessarily well equipped to understand how a ruling would impact the military.
Here's a good overview of the context for limiting the rights of military personnel: https://mtsu.edu/first-amendment/article/1131/military-perso...