The word used in this commandment can be translated as either kill or murder, however murder is generally considered a more contextually correct translation. As the New American Bible’s footnote states:
the Hebrew verb translated here as “kill” is often understood as “murder,” although it is in fact used in the Old Testament at times for unintentional acts of killing (e.g., Dt 4:41; Jos 20:3) and for legally sanctioned killing (Nm 35:30). The term may originally have designated any killing of another Israelite, including acts of manslaughter, for which the victim’s kin could exact vengeance. In the present context, it denotes the killing of one Israelite by another, motivated by hatred or the like (Nm 35:20; cf. Hos 6:9).
The word can have various meanings depending on its context. As the NAB notes the word is used in the Scriptures at times to refer to unintentional killing yet clearly a commandment that begins “thou shall not” cannot be referring to something unintentional. Exodus also proposes the death penalty for the violation of some laws, so clearly the commandment is not referring to killing of any kind. Essentially the commandment appears to be referring to illegal killing which is better understood as murder.
The Jewish people were not just any tribe, they were the chosen People of God. To enter into idol worship was not just apostasy but could be considered treason as well. As such, legal execution for treason still exists today even in countries that have laws against murder. The commandment (as well as civil laws) against murder do not tie the hands of the state from imposing capital punishment for certain crimes.