I actually happen to have done a slightly creepy amount of research into the phenomenon of 'crowd crush' and 'crowd collapse' recently, and can probably shed some light here. First I'll say these are not stampedes, but some background info is needed. IF YOU HAVE A WEAK STOMACH YOU MAY WANT TO CONSIDER NOT READING THIS.
Basically when people start to move in very high density crowds, each individual physically doesn't have enough space around them to behave like a normal person who acts based on decisions anymore, but rather the entire crowd starts moving like a fluid, forced forward by the pressure of the people walking forwards behind them. We're talking densities of 5+ people per square meter (you can roughly equate 4 people per square meter to being in a tightly packed crowd but still being able to move 360 degrees, just brushing up on people on all 4 sides. At about 5-6 people/meter2 you start to lose that freedom of movement). The crowd starts to literally behave by the laws of fluid dynamics, and can experience shockwaves that ripple up and back through the mass of people when a push comes from any given direction... anyone who's been in a moshpit knows what I'm talking about.
These crowd densities aren't dangerous in themselves until you start reaching more than 8+ people/meter2 , however starting at about 5-6 they become extremely risky to facilitate movement in for two major reasons: 1) the risk of hitting a choke point and 2) the risk of someone falling over.
The first one results in what is called 'crowd crush'. This is where you have an extremely large and high density crowd, typical for those seen at events like the Hajj, moving in one direction in a confined space. This can be as wide as a city block or as narrow as a hallway. The crowd will be moving in its desired direction, but as soon as it hits a choke point, such as a blocked entrance, a sharp turn, a single open doorway, or even another high density crowd coming from the opposite direction, the people at the front face a serious problem. They are not merely walking anymore, they are being carried in the crowd fluid and could not stop if they tried (and would probably fall over). Survivors of crushes have described the experience like you're being carried by a river of people. The people at the very front of the crowd (who are not at dangerous densities) will make it through the choke point, unless it's a blocked entrance of course, but the high density crowd inevitably follows, carried by force. If the choke point is too narrow for the entire crowd to fit through, people literally just plug it up and are unable to squeeze through the gap anymore, and are being evermore crushed by the force of people behind them. For a morbid but good example of this, watch the video of the Station Nightclub fire that happened in 2001 2003 (NSFW/NSFL). For those who don't want to watch, basically what happened is a fire broke out in a nightclub, and nobody really bothered to run for the emergency exits (plus some other things but another post entirely) but instead all pushed for the front door. When the crowd density trying to leave the club out of the double doors became too great, the people got stuck and knocked over in the doorway, and bodies kept piling on top of more bodies from the flow of people behind until there was a helpless 6ft high pile of people with their heads and arms sticking out the front door packed too tightly for anyone on the outside to wedge them free.
Here's the fucked up part though: people do not die from being 'trampled' as if everyone is wildly running around and stepping on each other, in fact there's literally no way that's possible because people couldn't be running around in high density crowds even if they wanted to. What they die from is compressive asphyxiation (yes, suffocation by crushing) from the sheer force of all of the weight of bodies being stacked on top of them. In the worst of choke points, a completely blocked exit, people can be crushed standing up because they breathe out and simply cannot overcome the pressure of all of the people around them to breathe back in. That happens at densities of about 12+ p/sqm. 'Crowd pressure' has been known to collapse walls, bend steel guard rails, and of course kill a shitload of people.
The next scenario, and in my opinion the much more horrifying one, is crowd collapse. This happens when a high density crowd is moving and someone falls over. If you can imagine yourself in a fluid-like crowd, the pressure of the person behind you pushes you forward, and in turn you exert the pressure on the person in front of you, facilitating the crowd's (the fluid's) movement. If suddenly the person in front of you falls, they are no longer there for you to 'lean on' (to exert pressure on to), and guess what? You fall too. And the person behind you. And the person behind them, and anyone who tries to help someone else up, all just being pushed against their will into the new wall of bodies in front of them. The crowd collapses behind the original hole. Aaaaand now you have a choke point, just made of bodies. Surprisingly even here the main cause of death is almost always compressive asphyxia rather than trampling, as the pressure just gets too great when you have 2000lb of flesh on top of you. The crowd doesn't even have to be moving very fast for this to happen (or even can be stationary in the case of a grandstand collapse ), and is especially dangerous when the people are moving down a steep or slippery slope.
Here's the kicker: in both of these scenarios the death tolls are so high because the people in the back of the crowd, propagating the crowd force, are almost always too far away to know what's going on at the crush point. These sorts of crowds are extremely noisy and essentially impossible to stick your head up and over to get a better view, this combined with the fact that the back of crowds are usually at safe densities and people have no reason to panic and just keep walking means that the people at the front have no choice but to be crushed. Or in the case of a fire, where people sometimes are aware of what's happening in the front, they will simply keep pushing because it's either that or wait to die, worsening the crush at the front. Hundreds upon hundreds of people can be screaming for help and for people to stop or turn back... the ones who can hear them are already too stuck in the flow to do anything, and the ones who can do something can't hear.
So now the Hajj. This annual event is basically something any Muslim (who is able) has to do in their lifetime, and involves traveling to Mecca and surrounding areas over the span of four days to perform some religious rituals and visitations etc. The super short timespan of this event and the insane amount of people it draws means there's a huge amount of high density crowd movement, and one of the most notorious areas is a city called Mina, by which a particular ritual called the Stoning of the Devil is performed. Basically people need to throw rocks at a particular set of pillars, and so as you can imagine there's a giant potential for dangerously packed crowds when you have to move so many people to such a small location. This particular one happened when one road was closed in Mina and people didn't follow the detour or something (the news isn't very reliable because these events become so political for some reason), and basically two extreme density crowds coming from opposite directions collided in a single intersection, causing the pileup you're reading about above. There was also extreme heat on that day; you'll get people dropping like flies once densities start to get crush-worthy. There has been a crush or a collapse at the Hajj that's killed hundreds of people roughly every two years for the past couple of decades.
In fact, the global rate of crushes has increased exponentially in the past 50 years or so as cities have become dense and urbanization is commonplace, this is a real problem that you may encounter in your own lifetime. If you do realize you're in a crowd that's heading towards a crush, unfortunately it probably means it's too late for you at that point. However, if you're actually serious about avoiding one of the most horrible deaths you could imagine, whenever you start to notice you're in a crowd that is reaching dangerous densities (4+) and is starting to behave like a fluid, you can work to get out of it. The key is the shockwaves you'll feel travel through everyone as the pressure pushing y'all starts to outpace how fast you can physically move. These are the sorts of crowds that if someone steps on your foot you'll probably lose your shoe because your foot will simply be carried out of it by the movement of the crowd. When you feel a shockwave, absolutely do not fight it. That's one of the quickest ways to fall over. What you should instead do is let it carry you wherever it needs to, and then immediately start moving sideways, and diagonally backwards if that's possible, avoid falling over at all costs though. You simply want to GET OUT of that crowd at that point (even if it's headed somewhere you needed to be) however possible. People may start dying. And you may be one of them.
EDIT: If you do every find yourself in the worst-case scenario and are knocked over, attempt to fall in a rigid fetal position (arms over your face and chest) to attempt to make room for your lungs to breathe. One man survived the Station Fire (NSFW/NSFL) by doing this and having a small supply of fresh air, protected from the fire by a man-made heat shield.