In the confusion of battle, the youth is separated from his regiment, then is caught among the chaotic ranks of another regiment which is fleeing from their own recent defeat under fire. The youth catches the arm of one frantic soldier, asking what happened, and when he will not let go the man takes his rifle and hits him across the head. The wound he inflicts appears as if the youth was grazed by a bullet.
The irony of the wound is that it looks like the youth sustained it in battle. Other soldiers, and the youth himself, look upon those who have been wounded as somehow having proven their bravery under fire - the wound is thus a "red badge of courage". The youth now has his "badge", and others look at him with respect, but he didn't get it by performing well under battle conditions, he got it by accident in the chaos and confusion which is the true reality of war.