I was not trolling and had not seen any in the dawn of war games or space marine 1 and 2 which were my primary experience with WH40k.
Because a bayonet is just a cheap spear, invented when muskets were a thing.
It is easier to give it to people than to have them carry a spear in addition to the gun. IG has it. Plus it can be a knife when needed too, so you get a lot of mileage out of it.
Space marines can just carry a dedicated melee weapon, they don't care about an extra 50 to 100 kilos.
In the Horus Heresy they were more mass produced, so it made more sense.
A Powersword also has better anti-armour characteristics, as it has a disruptor field, a type of scifi magic that makes things disintegrate. Like a star trek gun or a lightsaber, for normie reference, except there are no resistant materials. Energy shields/other power weapons do work against them.
After that you get the Thunder Hammer, that does this in an AOE fashion. And necron guns that, well shoot it.
Of course, for gameplay this is toned down, or anything smaller than a tank, dreadnought, carnifex or hive tyrant would get deleted by a single thunder hammer hit.
Dawn of War and Space Marine, while I love those franchises, they have like 1/3rd of the stuff they could put in because of practicality.