Human beings only come to understand God and God's will. This is not only true in our day, but also in Biblical times. The attitude towards violence in Scripture evolves. The Old Testament, especially early on, sees violence as a part of life. On the other hand, the New Testament in the teaching of Jesus is much stronger in restricting and condemning the use of violence.
In the O.T. the law of vendetta reigned. This attitude allowed people to take terrible revenge on one another when they had been wronged. If somebody wronged him, Lamech bragged that he got back at them 77 times as much. (Remember that Jesus said we were to forgive 70 times 7 times).
The Ten Commandments tried to limit the terrible vengeance and violence of the ancient world. Thus the 5th Commandment "Thou shalt not kill." Generally, this ws accepted to mean you should not murder. At first, these Commandments applied basically only withing the tribe of Israel.
Ex. 21:23-24 tries to limit violence by the law of "an eye for an eye and a tooth for a tooth." This was a limitation over the unlimited vengeance of earlier times. It tried to make violence at least proportional. But as Dr. Martin Luther King jr. noted, this law would leave the whole world "blind and toothless."
As to all the battles the Israelites fought to get the Promised Land, we should not see that as an endorsement of violence. The people of Israel were looking back on these events many years later and believed that they saw God's hand in these things. We have o say that we do not really know what God thought of the violence. We do know that the people of Israel believed God meant for them to have the land and gave it to them by God's power, not theirs.
Only gradually did the people of Israel begin to see that, if God was truly God of the whole world, then God's laws applied to everybody. This included God's law against killing.
It was not until the people of Israel returned from exile in Babylon that the prophets began to see that God calls all people to a place of peace, where the lamb wil lie down with the lion and people will not learn war anymore (Isaiah 2:4).
ONLY when we get to Jesus do we see a complete condemnation of violence. Jesus teaches us to love not only our friends and neighbors, but our enemies as well. He tells us in Matt. 5:43-48 and Luke 6:27-36 that we should love our enemies and pray for our persecutors. When a disciple draws a sword to defend Jesus, Jesus tells him, "Put away the sword, for all who take the sword will perish by the sword." (Mt. 26:52)
There are several attitudes toward violence in the Bible. As Christians, however, we listen to Jesus and the teaching in the New Testament over all others. Jesus was more opposed to the use of violence than any of the writers of the Old Testament. He showed this by his actions and his command to love everyone, even our enemies.