The bayonet was needed so you could ditch the spearmen next to you who was only there to intimidate enemies into not coming too close. And don't forget that before them you had literal gun swords (-axes, -shields, etc.). But the more firearms advanced the less useful melee weapons became.And yet someone took the time to invent the bayonet, which turns your rifle into a more effective mêlée weapon by adding a short sword-like blade to it.
Not so in D&D. Especially the escalating HP in D&D fundamentally alters the role of firearms and ranged weapon in general as it is simply not possible to kill an enemy with one attack once you are past level 1 no matter how good you are and what you do which removes the main advantage of ranged weapons.