The answer
The children of Israel lived at a time when it was necessary for them, being the only culture that had a real relationship with God, to keep themselves in purity, in every aspect and detail. They had to be governed by strict rules and guidelines. Yet, God was very patient with many nations that oppressed Israel. Nonetheless, He grew tired of the ongoing nonsense of the pagan cultures and their detestable corruption and violence toward His children. God did not want His children to have any share with any polluted environment. They needed to adhere to God's law and principles because they were assured that the Messiah was to come from the lineage of David the prophet, as He promised.
The examples you provide actually help us to perceive that God allows His children to engage in military obligations and operations. It is true that God did not only command us not to kill, but also to not oppress anyone, nor slander anyone's reputation because these forms of harassment are the most commonly used to could kill a person's drive, purpose, and self-esteem. Nehemiah knew how the women were accomplices in many despicable practices in the false faiths at that time. He was disappointed by the mixing of faiths, rather than just cultures. As we learn from Ruth and others, God had always wanted the Gentiles to be amongst His people, but it had to come from them. Many witnessed God's mighty arm in so many miracles and with so much power, and they knew there was no other like Him! God is kind and most compassionate with everyone.
Answered by His Eminence Metropolitan Youssef (opens in a new tab)