The most basic answer to this supposed contradiction is that both statements are true depending on the time and context.
With that in mind, let’s examine a couple different ways we can look at this.
First, consider the fact that war is often fought for the purpose of bringing about peace. During World War II, Europe and Asia were engulfed in fighting. Sitting on the sideline was the United States, hoping that this situation would be resolved without our involvement. The U.S. wanted peace, not war.
On December 7, 1941, Japanese pilots made a surprise attack on Pearl Harbor that launched the U.S. into war against Japan. That prompted Hitler to declare war on the US, bringing the country into both fronts. The U.S. became a nation of war in an effort to be a nation of peace and to help bring peace to the world at that time.
In the same way, God is a God of peace. He created an originally perfect, peaceful world that has been subjected to war only because of mankind’s rebellion. Of course, God knew this, had a plan for victory, and offers a time when peace will reign for eternity. However, bringing about this peace often includes the necessity of war.
The context of these passages is also significant. In Exodus, the oppressed Israelites had just been set free from their harsh oppressors, and God fought the battle at the crossing of the Red Sea. The beautiful metaphor in Exodus 15:3, “the Lord is a man of war,” reveals the ease, power, and control God had over the situation, doing battle against an oppressing army of Egyptians.
Furthermore, we must consider the recipients of war and the recipients of peace.
God has never promised peace to the wicked. In fact, He has stated exactly the opposite. “There is no peace, says the Lord, for the wicked” (Isaiah 48:22). The promises of peace in Romans 15 and elsewhere are given to God’s people alone.
We should also understand that the peace God gives does not always mean avoidance of trouble, but rather it means we will have God’s comfort and assurance while going through difficult times.
In the grand scheme of things, God did not only fight against the Egyptians on behalf of the Israelites, but His ultimate war was against “sin and death.”
Christ conquered these foes on the Cross and now offers peace to those who trust in Him. Paul expounds on this peace in Romans and other epistles (e.g., Romans 5:1, 10:15, 16:20; Philippians 4:7, 9; 1 Thessalonians 5:23; 2 Thessalonians 3:16; Hebrews 13:20).
A God of “war” and a God of “peace” are not in contradiction.