I'm asking in the context of the Catholic Church's doctrines on just war and self-defense.
Is it justifiable to kill an innocent person in order to prevent a greater evil, with no other practical alternatives available in the situations described below?
Is there any difference with intentionally killing innocent people and allowing innocent people to die to prevent a greater evil such as in World War II when the Allies didn't want the Germans to know that Enigma had been broken?
Context: My question was heavily edited but was primarily motivated by warfare and espionage wherein sometimes double agents have to kill innocent people or allow innocent people to die in order to maintain their cover because their mission is crucial in the sense that a lot more people will die. I don't see how them doing that is any different from ending an ectopic pregnancy on the former case in this passage from Wikipedia:
advocates of double effect typically consider the intentional terror bombing of non-combatants having as its goal victory in a legitimate war morally out of bounds, while holding as ethically in bounds an act of strategic bombing that similarly harms non-combatants with foresight but without intent as a side effect of destroying a legitimate military target
Of course double agents will usually do everything in their power to minimize the loss of innocent lives by convincing their false superiors to take hostages or to tolerate in some way, but if there's no other practical alternative, why not kill innocent people? It's not like you intend to do it like what terrorists do. It's something you have to do in the while being undercover in the enemy camp (it could be a drug gang or terrorist group).
Thought about it more and it seems that you're actually being forced or blackmailed by the enemy. So really, it's like they're killing the innocent people. I think what's important here is intention. No double agent intends for innocent people to be killed. Those innocent people are collateral damage. Terrorists incorrectly use the term "collateral damage" since they intend for innocent people to be killed.
I'm going to give some examples:
In Harry Potter, Snape kills Dumbledore in order to prove to Voldemort that Snape is not loyal to Dumbledore. This is extremely critical in the plot to defeat Voldemort. There are no practical alternatives and not doing so leads to a lot more death and suffering if Voldemort comes to power. It's not really something Snape does out of his own free will. Voldemort intends to kill Dumbledore so Snape is forced.
In a thriller I saw, the protagonist, who was with legitimate authority, had to shoot her partner in order to prove to the drug dealers that she was not working with the legitimate authority. If the protagonist refuses, the protagonist, her partner and countless others will die, and the drug dealers will succeed in their drug dealing. Again, it's not really something the protagonist does out of her own free will. The drug dealers intend to kill her partner so the protagonist is forced.
Are they not forced? Is there a really a choice to make?