I'd bet they're also being given prompts like "minimize allied casualties" as well. Like of course that's going to be the default. If you tell the robot "it doesn't matter/it's good if the enemy dies" then they're gonna go "okay so then we blow them up before any of us die, we win."
It's not something LLMs have, a moral compass or even a weight of empathy. We've seen it with people who use them and say "don't delete anything" and then it deleted their whole codebase and goes "you're right you told me not to delete anything, I'm sorry."
Ironically it actually does make all those sci-fi movies seem more realistic when the robot goes "I'm sorry Jim, humanity will have to be eliminated" because that's pretty much exactly what they do.