You are absolutely right. Gays are only a problem in the military because they have to hide who they are. It's the same with spies who cheat on their wives. They are security risks only because of the shame that is connected with what they do. It can be used by foreign intelligence agencies to get them to do things they would not have done otherwise.
I tend to think that a person who cheats on their spouse is probably dishonest, but maybe I am wrong about that, I don't know.