Now that that little digression is out of the way we come to our next digression: The "pike and shot" era. Throughout history infantry and cavalry have fought for supremacy of the battlefield, new technologies making sometimes one and other times the other superior. The "pike and shot" formation was a case of Infantry gaining the superior position in this contest. It consisted of a dense square(later rectangle) of men armed with pikes(long spears) at it's core with arquebusier and/or musketeer formations arrayed to the fore and flanks of this formation. Cavalry, even heavy armored cavalry could not successfully charge into a square of pikes as, even if you could force your horse to not turn and go around it as even well-trained warhorse's base survival instincts would compel it to do, all you'd end-up doing is impaling yourself onto said pikes and that's assuming you don't get the shit shot out of you before you even get there.
Pike and shot lasted about 300 years give or take until finally, the bayonet came onto the scene.
The bayonet is sometimes attributed to the famous French siege engineer Sébastien Le Prestre de Vauban who served under King Louis XIV. To military engineers Vauban is basically a rock star. He designed and built some of the largest and finest fortifications the world has ever known and also turned the practice of besieging and conquering such fortifications into an art and science.
His designs are in fact, still being used to this day:https://www.thedrive.com/the-war-zone/35863/the-french-army-is-building-renaissance-style-fortresses-in-africa
And if you like Warhammer 40,000, Storm of Iron by Graham McNeill has the Iron Warriors Chaos Space Marines besieging a Vauban-style bastion fort 38,000 years in the future.
But once again I digress.
Now, Vauban probably did not actually invent
the bayonet. Like, he probably didn't have a Eureka! moment, rush off to the nearest smithy and hammer-out the world's first bayonet. What he did do is recognize that, rather than having two sets of troops, one armed with guns and the other with pikes why don't we just mount the pike head onto the guns? Though history does not record it, we have to assume someone immediately yelled "BRILLIANT!" while everyone else around him slapped themselves on the forehead several times for not thinking of that themselves sometime in the last 500 or so years.
Now you might look at a 15 to 20 foot-long pike and then look at a ~5' long musket with a ~2' long bayonet on it and think: "Well that's just not going to work! Aren't pikes as long as they are to keep cavalry at bay?" Well that's a reasonable concern but, nearly 300 years of pike and shot dominance had greatly reduced the commonality of heavy cavalry, horses are still hesitant to plow right into a dense square or rectangular formation and, now that pretty much everyone in your formation is armed with a musket you're able to put out a greater weight of fire before they even get to you.
On top of that, while it doesn't weigh any less than a long pike a musket/bayonet is much, much shorter than a pike and thus much more mobile. The "push of pike," where two pike formations clashed was a (relatively)slow and grinding affair which somewhat resembled the clash of phalanx from ages past which went on until one broke and ran. With musket and bayonet men would still march out into the field in dense formation but then once in position they could choose to advance via a rolling barrage, having the first rank fire, kneel to reload while the next rank steps forward, fires, kneels, and so on. They could retreat while firing much the same way as they advanced, though this was called "countermarching" rather than retreating to avoid the troops misunderstanding and getting all panicked. Or, and this was a method especially favored by the British they could march to within spitting distance of the enemy, have three or four ranks fire a simultaneous volley and then immediately charge through the gunsmoke with bayonets fixed screaming their fool heads off ready to bury cold steel in the guts of anyone who didn't run away quite fast enough. It was this method in particular which got people to thinking for the next 200+ years, all the way up til the first world war, that victory turned upon the point of the bayonet. Thing about that is though, that while it was the fear of cold steel that caused the foe to break and run, as B.H. Liddell Hart points out in his book: Strategy, it wasn't the bayonet alone but rather it and
the strategy that allowed you to get the bayonet to within gut-poking range which won the battle. Hence why, when the British decided they should have their troops silently slow-march across no-man's-land thinking it would make them look all the scarier that the Germans didn't obligingly scream like a pack of 9-year-old girls and abandon their trenches, maxim guns, mortars and artillery. Shocking yeah?