Comments on bible reading

I’ve been reading through the book of Joshua in the bible and it’s a pretty violent book as Joshua slays the kings and kingdoms around him. I frequently see the term smote with the edge of the sword. However this is in stark contrast to what Jesus says in the new testament that he who lives by the sword will perish by the sword. I don’t see how these two events collaborate with each other. I still believe the Bible is the word of God but I have some difficulty in understanding these opposite actions found in the bible.