Gavin, one is a crime and the other is only a sin. However, Article 32 of the Uniform Code of Military Justice (UCMJ) covers most sins, and makes them illegal for military members. Homosexuality, adultery, sodomy, etc. are all covered and all illegal. Fraternization is also covered.
These things are made crimes to enforce discipline and order in the military. The UCMJ extends US Federal law to cover military members worldwide, so in addition to local laws in foreign countries we also fall under US law. As you can imagine, almost everyone at one time or another bends or breaks these rules. Whether you are prosecuted depends on the situation and whether it impacts the military in a negative way.