In the Old Testament, when God ordered the Israelites to kill various groups of people, the people being killed were always under judgement from God for their sins. The Canaanites were particularly evil people who practiced idolatry, including brutal infant sacrifices. As such, it could be argued that the people were guilty under the law and therefore, killing them would be a matter of capital punishment rather than murder. As others have made clear, the Ten Commandments prohibit murder, not all killing. The Mosaic Law includes capital punishment as a recourse for many crimes, so clearly, in context, the Ten Commandments were not intended to outlaw all killing.
That explanation, however, is not, in my mind sufficient to answering the question. For instance, that doesn't explain why it was just for the Israelites to kill babies. Surely it cannot be said that the Canaanite infants were any more guilty of breaking the Mosaic Law than the Israelite babies were. To answer the question of why it was just for the Israelites to kill innocent babies, you must go beyond a simple murder-versus-capital-punishment explanation.
One answer to that question is that God is omnipotent and omniscient. When we murder someone, it is wrong because we have taken something away that we cannot give back. We do not have the power to give the person their life back. When God takes someone's life, not only is it in his power to give it back to them, it was He who lent it to them in the first place.
Similarly, when we carry out capital punishment, we take great pains to ensure that we do not wrongly convict the innocent. When God carries out capital punishment, he definitively knows, not only the persons guilt or innocence, but also their future decisions. He knows whether or not they would ever repent if they were given the opportunity to do so.
Therefore, if it's just for God to directly apply capital punishment, as in the case of Sodom and Gomorrah, it is also just for him to ask an executioner to carry out the punishment for him, as in the examples you mentioned.
Concerning any killings that have been carried out by the Church, Catholic or otherwise: it cannot be said that God condoned those killings merely because they were performed in His name. If Bob murders Sam and claims that Marty made him do it, that doesn't necessarily mean that Marty condoned it. It's only true that Marty condoned it if what Bob claimed actually was true. It's fallacious reasoning to claim that a religion supports murder merely because some of its adherents are guilty of it.