It's just a subconscious bracing movement. You see something horrible, so you brace yourself for when it happens, without you even thinking about
it. You may tense, you'll have a sharp intake of oxygen, and adrenaline will start to be released into your blood. It's part of our "fight or
flight" mechanism, and it's your body making sure it's done everything it can to let you either get the hell out of dodge, or (try to) beat seven
shades of crap out of someone, whichever makes more sense to the person in question.
Not everyone will gasp at the same things. If you're already hopped up on adrenaline, your "fight or flight" mechanism won't kick in (as you're
already set for adrenaline), or if the scene doesn't provoke the same emotional response, you won't gasp. Police, soldiers, doctors, etc. won't
gasp at a car crash as much as, say, you or I.
The reason some people will help the attacked person is all down to the individual. Those who are less shaken up will help first, those who are more
shaken up will be less useful to others (as they're still trying to figure out how the situation relates to them, whether they're OK, whether they
believe what they just saw, etc.). And once the first wave of people have started to help, others won't, as they simply don't have to.
Humans are individuals (at least on that level), and we react as people. Though our reactions are affected by the crowd of people we're in.
At this point, though, we get down to what sort of a person these individuals are. If you were robbed in front of, say, 15 soldiers on R&R, chances
are all of them will leap to your aid. They're not shocked by it, and their instincts tell them that all their buddies are on board as well.
Replace that 15 with 15 non-soldiers, and even if they want to help, they'll check each other for subconscious (and maybe even conscious) signals
that they'll all help at once.
This is more of a psychological question than anything hitherto-unknown. It's still very, very interesting though. Nice one