read this first
vatican.va/archive/ENG0015/__P7Z.HTM
Legitimate defense
2263 The legitimate defense of persons and societies is not an exception to the prohibition against the murder of the innocent that constitutes intentional killing. "The act of self-defense can have a double effect: the preservation of one’s own life; and the killing of the aggressor… the one is intended, the other is not."65
2264 Love toward oneself remains a fundamental principle of morality. Therefore it is legitimate to insist on respect for one’s own right to life. Someone who
defends his life is not guilty of murder even if he is forced to deal his aggressor a lethal blow:
If a man in
self-defense uses more than
necessary violence, it will be unlawful: whereas if he repels force with
moderation, his defense will be lawful… Nor is it necessary for salvation that a man omit the act of moderate self-defense to avoid killing the other man, since o
ne is bound to take more care of one’s own life than of another’s.
2265 Legitimate defense can be not only a right but a grave duty for someone responsible for another’s life. Preserving the common good requires rendering the unjust aggressor unable to inflict harm. To this end, those holding legitimate authority have the right to
repel by armed force aggressors against the civil community entrusted to their charge.66
Killing in self defence is fine, when it is the only option. Putting yourself in the situation to kill another via self defence is not. for example, if someone breaks into your house and in trying to subdue them they accidentally die, that is no sin. If someone breaks into your house and you kill them when it would have been possible to have stopped them without killing, there is a sin. If you are a soldier defending your homeland from invasion by repelling the enemy, that is no sin. if you are a soldier, and have invaded anothers homeland and kill whilst the other soldiers are trying to repel you, you have sinned.
The fifth commandment forbids doing anything with the intention of indirectly bringing about a person’s death. the moral law prohibits exposing someone to mortal danger without grave reason, as well as refusing assistance to a person in danger.
The acceptance by human society of murderous famines, without efforts to remedy them, is a scandalous injustice and a grave offense. Those whose usurious and avaricious dealings lead to the hunger and death of their brethren in the human family indirectly commit homicide, which is imputable to them.
Unintentional killing is not morally imputable. But one is not exonerated from grave offense if, without proportionate reasons, he has acted in a way that brings about someone’s death, even without the intention to do so.