When you read, "Thou shalt not kill" or "Thou shalt not murder" don't think only in terms of the earthly life. This does not condemn self defense or defense of ones family or even country. "Kill" is a very heavy word in this context.
I've had to confess the killing of my mother in my mind (not in the sense of physically murdering her), I kill her spiritually out of resentment and anger, my stubbornness to forgive. I cause her great harm out of this which causes myself and Christ harm.
A good example is the death penalty. The death penalty is right and just in the eyes of God, if done justly and in His name. A Godless country has no right to wield the sword against a man. In the case of a Godly society and Godly court, the death penalty while meant to end the earthly life of a man and do justice for society, is intended to save the soul of the man. A man is given a definite end, a tangible end of life, for the purpose of leading him to repentance and forgiveness, in an attempt to save his heavenly life.
There are endless biblical examples of righteous killing, the killing of Gods enemies.
Then there is the ultimate proof, God has ended the earthly life of men, women, and children. The flood, the plague, enemies of Israel, Sodom and Gomorrah, etc. God can not contradict Good or Truth because He IS Good and Truth, He can not break His own commandments.
Killing in the True name of God, is not only permitted, but righteous.
Now on the flip side, if for example I killed a man in self defense while I was committing a sin that led to his attack of me, let's say burglarizing his home, I would not be justified.
If I were a Judge and sentenced a man to death for failing to uphold the gospel of the skittles mafia, that penalty of death would not be just. Not only would I be in violation of the commandment, but so would the executioner and anyone else complicit in the societal culture that killed that man for blaspheming their religion of wokeness.