It was not easy to assault an enemy formation even though the rate of fire was low. The effect of a point blank salvo was devastating. Firepower by Major-General BP Hughes has some examples of it.

At Blenheim in 1704 where 5 English battalions lost about a third of its strength in just one salvo from the French defenders, fired at about a distance of 30 paces. He estimates it to about 20% of all muskets fired found a target.

At Fontenoy 1745 the English attackers did get the first salvo, also at 30 paces, with about 25% of the muskets hit. Its described how some of the French battalions lost their whole front rank in just one salvo.

Losses like that is enough to disrupt an enemy unit so any further advance would most likely cause a quick rout before any actual melee started.
Yes, I can see that, although it must be a moot point whether one volley at 30 yards was any worse than four at 100 yards. And the charging infantry would of course have their own volley, as the Fontenoy case showed.

There's another thing, which is that if you are getting 25% hits at 30 yards, 75% of your infantry are not contributing killing power to the battle. (I realise that is too simplistic because of course you need the 100% firing to get the 25% hits, muskets being what they were. Say that you cause casualties of 25% of your number then). Whereas bayonet to bayonet, even in three lines, 33% of the infantry are directly engaged in killing the enemy (and vice versa of course). And whats more I think a bayonet duel would last less time that the 30 seconds needed to get off a musket ball (I have never fenced with a bayonet, but I have with a foil, and if you are both going for the point you rarely have to wait even ten seconds for a hit) So if we said the average bayonet duel would produce a casualty in, say, 20 seconds (which is surely very conservative indeed), and you have third of your infantry causing casualties rather than a quarter, you are causing (and taking) casualties at, err, roughly double the rate, if my maths is right.

Ultimately I think the reasons for prefering volleys to closing to hand to hand must be psychological?