Wow, the set up is a mess, just wow.
Any army worth its salt ensures that professional/trained soldiers using ranged weapons have a mêlée weapon on hand, in case an enemy combatant gets too close. That's a historical constant.
Additionally, ranged weapons — especially firearms — can fail in various ways, so the mêlée weapons double as backup.
The basic army combat-cum-utility knife also works as a bayonet for this reason. (So, someone running out of ammunition or having their gun jam doesn't leave them sitting ducks.)
The Japanese bayonet-knife is notable for being longer than is usual for modern warfare in order to act as a deterrent weapon to boot. Which makes the error here, in a Japanese work, all the more glaring.
Also, the fight-or-flight response in humans as a whole tends not to be tilted that far on one direction or another, with combatants tending towards "fight" (due to a combination of job selection and training). So there is no way that all the soldiers in that situation would just flee rather than try anything and everything in their arsenals. Many of those guys are tough as nails.