Balak’s attempts to curse Israel into oblivion had failed, and now his conspiracy with the Midianites to trick Israel into leaving God’s will had also failed. The whole episode had made these Midianites an existential threat to Israel, and they were dealt with according to the rough justice of the day.
The Israelite ringleaders were executed, a plague had wiped out the other offenders (see Deuteronomy 4:3-4), and the rest of the community was ready to launch a counterattack.
There is no record of what happened to Balak, but Balaam was killed, as were the five Midianite kings who were there, men and boys, and most of the women (who were held responsible for leading the Israelites into idolatry).
The Israelites lost no men in the battle. Their captains’ response was:
31:50 So we are presenting the items of gold we captured as an offering to the Lord from our share of the plunder … 54So Moses and Eleazar the priest accepted the gifts from the generals and captains and brought the gold to the Tabernacle as a reminder to the Lord that the people of Israel belong to him.
The military cost to the Moabites who were were directly involved isn’t recorded. They got to keep their land because they were Lot’s descendants, but they lost their right to enter God’s presence (Deuteronomy 23:3-6).