If you are seeking analogy he had a trolley problem where 5 people are his family and on the other track there is a guy who commited serious crime, maybe killing, some believe it was even a murder. Everyone around agrees he should make every effort possible to throw the switch while he himself is led to believe that he's throwing training switch and even after throwing real switch the bad guy will rather be maimed not killed.
Still, he throws the switch, it was the real switch, guy is killed and eventually it turns out his offence was an accident and if left alone the trolley wouldn't kill 5 people.
Ender is guilty of killng a guy even though what he did was perfectly reasonable considering circumstances.