To preserve the culture of honor in the military. They have strict consequences for enlisted and officer alike if one is caught in adultery regarding hetero relationships. Besides choosing to be gay is a lifestyle choice not an intrinsic or God given difference that warrants constitutional protection. God created men to be with and love women in romantic ways. Gayness perverts the views that God is a father or viewing God as husband. I'd propose that anyone that gets married who has enlisted is to immediately be given a year off upon the wedding be with his wife and bring her joy then resume service. Even in times of war.
And the 40% of the people on this site that are gay/bi all say in unison: Being gay is not a choice.