In the Jataka Tales in the Buddhist Canon, there is the story of the Buddha-To-Be in a past life who killed a would-be murderer to save 500 people, as follows:
And he thought, ‘if I were to kill this person, I would likewise burn in the great hells for one hundred-thousand eons because of it. Yet I
can bear to experience the pain of the great hells, that this person
not slay these five hundred merchants and develop so much evil karma.
I will kill this person myself. Accordingly, the
captain Great Compassionate protected those five hundred merchants and
protected that person from going to the great hells, by deliberately
stabbing and slaying that person who was a robber with a spear, with
great compassion and skill in means.
The results of kamma is are known in the heart. If the terrorists are real terrorists then those who act to protect innocent people from terrorists are not really performing bad karma. While a cleanser of terrorists may feel stress & trauma, they can always reassure themselves they did a deed to protect people.
For example, in many civil wars, such as in Sri Lanka, it is difficult to judge if one-side is righteous. But in pure terrorism, it is without dispute that terrorism is evil. In other words, any person killing unarmed civilians is a terrorist. The Dhammapada states:
137. He who inflicts violence on those who are unarmed and offends those who are inoffensive, will soon come upon one of these ten
states:
138-140 Sharp pain, or disaster, bodily injury, serious illness, or derangement of mind, trouble from the government, or grave charges,
loss of relatives, or loss of wealth, or houses destroyed by ravaging
fire; upon dissolution of the body that ignorant man is born in hell.
The Pali suttas state it is the duty of the government to provide protection for the people, as follows:
But what, sire, is this Ariyan duty of a Wheel-turning Monarch?
This, dear son, that thou, leaning on the Norm [the Law of truth and righteousness] honouring, respecting and revering it, doing homage to
it, hallowing it, being thyself a Norm-banner, a Norm-signal, having
the Norm as thy master, shouldst provide the right watch, ward, and
protection for thine own folk, for the army, for the nobles, for
vassals, for brahmins, and householders, for town and country
dwellers, for the religious world, and for beasts and birds.
DN 26
In Buddhism, monks are forbidden to kill a person or instruct to kill a person, for any reason. But for Buddhist laypeople, taking life is a training rule rather than a commandment. Buddhism does not prohibit people from doing their duty to protect their family & nation. A monk informs people about the potential results of their actions (kamma); that is all.
The Buddha taught kamma is intention. If killing is done from a greedy or hateful intention, this is bad kamma. But if killing is done with compassion for life, this is not bad kamma.
The results of kamma are only known within the heart. The heart knows.
For example, the people in this video are heroes. It can be seen with the heart how their hearts have compassion rather than hatred & violence. These people defeated foreign terrorists & restored their nation to civility & normality (rather than harmed people). After they won, the many people celebrated Xmas & dancing with freedom, as shown in this video.