Although some individuals can follow contrary ethical guidance, most can not. Although a person may tailor their behavior to the situation, character usually shines through regardless of the situation. Generally a person who honors oaths will try to honor all oaths, and one who doesn't honor oaths can not be predicted. Moreover, the more stressful the situation the more likely fundamental character will show through. Because military situations are especially stressful, we can expect that true character rather than situational role-playing will come out in the military context.
Character is like a river.
The longer it remains in a particular channel the deeper it cuts and the less likely it will leave that channel. Rivers that frequently leave their banks to explore other routes pick up enormous amounts of mud and silt, clog their original channels, and sometimes wind up permanently in other channels. Most rivers remain within their channels indefinitely. People may occasionally slip out of their channel, but most will remain true to their character indefinitely. A person may for a short time behave morally among military peers and immorally otherwise, but over time, and perhaps in the most stressful situation, they will likely fail to maintain the false persona.