There's a striking anomaly at the beginning of parsha Matot. In the midst of the Midianite war, the parsha of vows appears. What is to be gleaned from this?
A relative of mine expressed an idea that seems quite relevant and can solve a question below.
He said there are two kinds of wars, a voluntary kind and one that's commanded. When thinking of vows, one has the option to voluntarily take an oath or not, and if he does, then he's commanded to uphold it. This speaks to wars as well, which can either be voluntary or be considered a command.
Applying this from a Hashkafic point of view, there's the voluntary war against our spiritual enemy, the yetzer hara, that should always be engaged in, but of course, once he is penetrating us, it's mandatory to fight and try to defeat him.
Probing further, vows are symbolic of words, of speech, while wars are physical engagements.
The Torah is conveying that speech, which is needed to make promises, is the force that determines the outcomes of wars, but more than that, the world was built by ten sayings uttered by G-d, which put everything in motion.
In reviewing our history, promises to the Avot have ensured our survival, and people's prayers have pacified G-d. Expression is at the core of our existence.
To further analyze the question of vows being placed specifically by the Midianite war, a point of emphasis can be whether in fact this was voluntary or a command. Of course, G-d commands the Israelites to go to war, and yet the Rambam doesn’t count this as a war under the rubric of milchemes mitzvah. It can be argued that even the Rambam would agree because of the explicit command. Nonetheless, it would require further study.
It could be, therefore, that the laws of vows are placed in this exact place to instruct us of the need to contemplate what category of war was taking place, though there is a specific command. Also, it sensitizes us to the connection between speech and war, as speech is the controlling factor in the outcomes of war.