The key word is melee. Why did people use swords long after guns have been invented? Precisely, because a gun might not be the best choice of weapon if you oppose an enemy in a short distance.
It's just the usual, today different standards apply then in the 60s. A small continuity glitch today and fans go cracy, a bit of silly humour or dialogue and the hardcores gather the wood. You make Trouble with Tribbles and the goofiness is celebrated, you make a Night in Sickbay and people complain about the silliness.