The Hebrew nation was being used as an instrument of judgment. They were told which tribes to attack and which to leave alone. The ten commandments say thou shall not kill, but in this sense the Hebrews were not killing, god was.
I think you're referring to Joshua and Judges, after Moses. The interpretation of the word "kill" varies, but most agree it has to do with intentionally killing someone out of anger, frequently vengeance. I can't speculate at this time why Joshua killed so many tribes, but the period in Judges is portrayed as a tragedy in Israel's history and is not encouraged. Recall that Joshua through Chronicles was written from the perspective of Israel's history. Just because Israel gloats over victory does not mean it is truly God's desire.
To answer the question whether God breaks His own commandments, we need to determine if God committed murder (i.e., killed people without cause). The Bible is quite clear that God has killed people directly (the most prominent example being the flood) and indirectly (ordered peoples to be killed). If God ordered or participated in the killing of innocent people, then He would be guilty of murder. Let's look at two of the most prominent examples.The flood According to the Bible, God killed every human except Noah, his wife, his sons, and their wives in the flood. Were any of these people killed unjustly? The Bible says specifically that all people (except Noah and his family) had become corrupted.12 Not only had all people become corrupted, but they were continually plotting evil!13 Is it possible that an entire culture can become corrupted? You bet! Recent history proves the point rather well. When the Nazis took over Germany before WWII, opposition was crushed and removed. When they began their purging of the undesirables (e.g., the Jews), virtually the entire society went along with the plan. Further examples are given on another page. So, the Bible indicates that no innocent people were killed in the flood.God orders killing What about when God ordered Joshua and his people to kill every man, woman and child in Canaan?14 What crime could be so great that entire populations of cities were designated for destruction? God told Moses that the nations that the Hebrew were replacing were wicked.15 How "wicked" were these people? The text tells us that they were burning their own sons and daughters in sacrifices to their gods.16 So we see that these people were not really innocent. For these reasons (and others17), God ordered the destruction of the peoples whom the Israelites dispossessed. see comments for conclusion
The Old Testament records God killing multitudes of people, and some people want to believe this makes Him a murderer. The misconception that "killing" and "murder" are synonymous is partially based on the King James mistranslation of the sixth commandment, which reads, "Thou shalt not kill" (Exodus 20:13). However, the word kill is a translation of the Hebrew word ratsach, which nearly always refers to intentional killing without cause. The correct rendering of this word is "murder," and all modern translations render the command as "You shall not murder." The Bible in Basic English best conveys its meaning: "Do not put anyone to death without cause." http://www.gotquestions.org/God-killing.html
The original hebrew wird translated as 'kill' actually translates more directly as 'murder'. Thou shat not murder. In a justifiable war against ones enemies it is acceptible to a point ie killing opposing soldiers or wartiors, not slaughtering innocents and civilians. Principles of the Just War A just war can only be waged as a last resort. All non-violent options must be exhausted before the use of force can be justified. A war is just only if it is waged by a legitimate authority. Even just causes cannot be served by actions taken by individuals or groups who do not constitute an authority sanctioned by whatever the society and outsiders to the society deem legitimate. A just war can only be fought to redress a wrong suffered. For example, self-defense against an armed attack is always considered to be a just cause (although the justice of the cause is not sufficient--see point #4). Further, a just war can only be fought with "right" intentions: the only permissible objective of a just war is to redress the injury. A war can only be just if it is fought with a reasonable chance of success. Deaths and injury incurred in a hopeless cause are not morally justifiable. The ultimate goal of a just war is to re-establish peace. More specifically, the peace established after the war must be preferable to the peace that would have prevailed if the war had not been fought. The violence used in the war must be proportional to the injury suffered. States are prohibited from using force not necessary to attain the limited objective of addressing the injury suffered. The weapons used in war must discriminate between combatants and non-combatants. Civilians are never permissible targets of war, and every effort must be taken to avoid killing civilians. The deaths of civilians are justified only if they are unavoidable victims of a deliberate attack on a military target. - In the case of Moses the enemies were enemies of God, worshipping pagan idols, making human sacrifices including their own children, engaging in religion based orgies, prostitution and homosexuality, etc. they were completely corrupted peoples and yes God led His people to slaughter them.