Depends how crowded the area is. A gun will need reloading. A knife will not.Plenty where it's been from well outside of arms length though...
Much of the time if you had someone with a knife, and someone with a gun doing the same attack at the same place the knife attacker would barely get anyone as they have to get much closer, take longer (and more physical effort), and can be defeated by things like simple internal doors or even just keep an object (table/car) etc in the way.
I agree that in some situations a gun is more effective, but the knife is in others, its very situational.
I think another problem could be people are more scared of a gun vs a knife so someone is less likely to run towards them or try and stop them.