As played out in the recent posts, there's a lot of the Bible that speaks of the necessity of killing, and a lot that prohibits it. Knowing that the Bible never contradicts itself, for all 73 books are essentially written by the same Holy Spirit, we must find a way that all this works together.
Fortunately, Christ didn't leave the job of Biblical interpretation to the wildly different views of everyone who reads it; He left us a Magisterium to interpret it properly, with the guidance of the Holy Spirit, and 2,000 years of wisdom to analyze Sacred Scripture.
Catechism of the Catholic Church:
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 one is bound to take more care of one's own life than of another's. [Thomas Aquinas]
2265 Legitimate defense can be not only a right but a grave duty for one who is responsible for the lives of others. The defense of the common good requires that an unjust aggressor be rendered unable to cause harm. For this reason, those who legitimately hold authority also have the right to use arms to repel aggressors against the civil community entrusted to their responsibility.
2266 The efforts of the state to curb the spread of behavior harmful to people's rights and to the basic rules of civil society correspond to the requirement of safeguarding the common good. Legitimate public authority has the right and duty to inflict punishment proportionate to the gravity of the offense. Punishment has the primary aim of redressing the disorder introduced by the offense. When it is willingly accepted by the guilty party, it assumes the value of expiation. Punishment then, in addition to defending public order and protecting people's safety, has a medicinal purpose: as far as possible, it must contribute to the correction of the guilty party. [Cf. Luke 23:40-43]
...
2320 The murder of a human being is gravely contrary to the dignity of the person and the holiness of the Creator.
2321 The prohibition of murder does not abrogate the right to render an unjust aggressor unable to inflict harm. Legitimate defense is a grave duty for whoever is responsible for the lives of others or the common good.
Catechism of the Catholic Church - The fifth commandment