For example, I read about a duel in which a British officer was fatally wounded by a Hessian officer during the American Revolutionary War. The Hessian was then pardoned by a British general. These two fought on the same side, and most likely the British officer was in some level of the aristocracy. Now his men are without their commanding officer, his family potentially destroyed, and there is a potential for bad blood to fester even more among the ranks. Honor aside, needlessly losing an officer, especially deployed during active war, has to have been recognized as a detriment to the army and a terrible waste of human life. Why were these duels not forbidden by military leaders?
For countries that saw strong dueling cultures, the position of the duel was in a kind of Catch-22 position within the military, legally prohibited, but socially expected to the point where an officer who refused a duel because of obedience to the law might find himself cashiered from the service for breaking the bounds of honor. Focused on the Royal Navy, this older answer might be of interest for you as it goes into more depth, and this speaks a little about the American Army.