Knives are close range, silent, and can function in a variety of angles quite easily and rapidly. Guns are longer range and are usually not as easy to change directions.
I'd prefer to keep any assailants at a distance. If they get in that close where I can't shoot them, I'm already dead