Just very rarely. That's why these things usually happen in schools, churches, at the movies and in nightclubs. Also, most of the shooters do end up killing themselves anyway.

The more guns you put in schools, churches, movie theaters, and nightclubs (especially in nightclubs where a lot of people get drunk), the more likely you're going to have accidental gun deaths or injuries there, far more likely than that guns in those locations will stop a mass shooting. We already know what works in other first world countries. Minimizing the number of guns minimizes the number of gun deaths.

That almost all mass shootings happen in places where people are defenseless. Sure, there will probably be more accidents if people were armed, but that doesn't change that fact. It's why you almost never hear about people going into police stations and opening fire, or shootings that happen when there's massive security or lockdowns. Also, saying that less guns equal less gun deaths is like saying that less knives equal less stabbing incidents or less drugs equal less drug deaths (And if banning drugs worked out, we wouldn't have the drug problem that we do now.).