To be sure, we almost exclusively see Starfleet starship crews in combat. Their equipment might be drastically different from that of Starfleet ground fighters.
But I gather it's a doctrinal issue, mainly. To allow the enemy to reach bayonet range would mean defeat already in the Starfleet doctrine, so there's no point in distributing bayonets. The average phaser-wielding Starfleet warrior is analogous to a heavy machine gunner: his task is to kill everybody at medium ranges already, and the lethality of his weapon grows to damn near 100% at close ranges. He can stop entire armies of bayonet-armed enemies at the push of a trigger, much as in "The Omega Glory". It's his own damn fault if he lets somebody proceed from medium through short to point blank range!
A hand phaser should be the ultimate close combat weapon. It has none of the shortcomings of today's firearms in this respect: it's not so long and clumsy as a rifle, assault rifle or submachine gun that it could be knocked aside in a melee, and it's not limited in ammo like a handgun. You don't even need to hold it in a specific way to be able to safely fire it, as there is no recoil or ejection of casings.
What advantage might a knife have over a hand phaser? The only one I can think of is that a phaser fired at extreme proximity just might harm the good guy, too. Witness "What Are Little Girls Made Of?" and the suicide-murder by Andrea the Android.
Timo Saloniemi