If you hear gunshots, then the first thing you immediately need to do is take cover. Cover is defined as getting behind something that will stop a bullet flying your way. Concealment is also good, but cover is the most important first thing.
The next thing you need to do is assess the situation. Where is the gunfire coming from and how far away from you is it? Concealment in addition to cover then becomes your second most important priority.
The third step then depends on whether you yourself are also equally armed, and not outgunned. At that point you need to determine if you can reasonably stand your own ground against the shooter.
If the shooter outguns you, then you need to stay concealed, or escape, because in a confrontation with someone who outguns you, you stand less than a 50% chance. And even a 50% chance itself when your life is at stake is not good odds.
Therefore in most cases, whether armed or unarmed, escaping and getting away are the most feasible and intelligent actions to take.
And even if you are armed, unless you were trained and are still proficient at shooting accurately under combat stress, either by the military as a combat vet or by the law enforcement agencies and you have been in the situation before, you would still be taking your life into your own hands by making a stand against a shooter when you are alone without any backup.
Ergo it is always better to let the SWAT team handle this.
If you are confronted and cornered by the shooter, then yes, you should rush him/her and grab whatever is available to use as a weapon. With luck and with speed you may prevail, however the odds are significantly LESS than 50% that you will succeed.
Q.E.D.