The principle to protect the innocent is fundamental and extends to the three levels of human life: the individual, the family and society or the nation.
The right to self-defense is a basic tenet of natural law. It is based on love of self. It is rightly claimed that we cannot love others unless we first have a proper love of self.
This does not mean liking everything about oneself; that would lead to an unhealthy egoism that demotivates one from becoming better, seeking God and overcoming sin and vice. It means caring for oneself — one's life, health and well-being. Protecting the self from disease, accident, wild animals and unjust aggressors is appropriate common-sense self-love.
According to section 2264 of the Catechism of the Catholic Church (CCC), one can therefore protect oneself from an unjust aggressor, even if a lethal blow is necessary to stop him. Nonetheless, even in this action, love of neighbor does not cease. The moral objective is not to kill the aggressor, but to stop him, the Catechism says, in section 2263. If a fatal blow is the only way to stop the unjust aggressor, he is at fault for his death, not the victim.
Protecting the innocent extends past the self. In fact, section 2265 of the Catechism states one has a right to protect the innocent, but also a "grave duty" to protect those under one's care. In other words, one has a moral option to save self, but a moral duty to save those under one's care.
In the rare case that one's own death may bring about a greater good, a person has the option to allow the unjust aggressor to take his life. He can never take it himself, for that would be self-murder or suicide, according to section 2280–83 of the Catechism. Obvious examples are the martyrs and Christ's sacrifice of Himself; but one can also think of a soldier taking a grenade in order to save his fellow fighters on the battlefield, or a man dying while trying to save his neighbor from a burning house.
This relates to the moral duty to protect those under one's care — like a father risking his life to confront a home invader to protect his sleeping children, a bishop dying to protect his flock from spiritual danger, or a president (and Congress) whose duty it is to protect his nation's citizens from unjust aggressors. These are cases where legitimate defense is not only a right, but a moral obligation.
The Church's traditional teaching on legitimate defense also extends to just wars and capital punishment — if the strict conditions are met in each. The four criteria of the Just War doctrine are spelled out in section 2309 of the Catechism.
The necessity for capital punishment today, stated by Pope St. John Paul II, to protect the innocent from an unjust aggressor "is rare, if not practically nonexistent," says section 2267 of the Catechism. Pope Francis goes a bit further by using the word "inadmissible," which, for the sake of intelligibility, may need a little more expounding upon and clarity as time goes forward.
One can never intentionally kill an innocent human being, which is the underlying principle behind the Fifth Commandment. Defending the innocent is a moral tenet from which none of us are exempt. It takes on different forms depending on one's vocation, job and other circumstances, and it is born out of love of neighbor and of self — stemming from love of God as the First Commandment delineates.
Watch the Church Militant panel explain more about Church teaching on protecting the innocent: The Download—Catholics and Defense.