Ksatriyas are allowed to commit violence in that way because violence for a good purpose is a part of their duty
SB Canto 3
The tour you have undertaken, O lord, is surely intended to protect the virtuous and kill the demons, since you embody the protecting energy of Śrī Hari.
It appears from many Vedic literatures, especially histories like Śrīmad-Bhāgavatam and the purāṇas, that the pious kings of old used to tour their kingdoms in order to give protection to the pious citizens and to chastise or kill the impious. Sometimes they used to kill animals in the forests to practice the killing art because without such practice they would not be able to kill the undesirable elements. Kṣatriyas are allowed to commit violence in that way because violence for a good purpose is a part of their duty. Here two terms are clearly mentioned: vadhāya, "for the purpose of killing," and asatām, "those who are undesirable." The protecting energy of the king is supposed to be the energy of the Supreme Lord. In Bhagavad-gītā (4.8) the Lord says, paritrāṇāya sādhūnāṁ vināśāya ca duṣkṛtām. The Lord descends to give protection to the pious and to kill the demons. The potency, therefore, to give protection to the pious and kill the demons or undesirables is directly an energy from the Supreme Lord, and the king or the chief executive of the state is supposed to possess such energy. In this age it is very difficult to find such a head of state who is expert in killing the undesirables. Modern heads of state sit very nicely in their palaces and try without reason to kill innocent persons.