As it refers to cattle, probably from the Spanish word "Estampidea" which means that the herd becomes "spooked" and takes off running wild. This was more of a problem on long trail drives, as they were being taken to market because the cattle were constantly in unknown territory. Longhorn cattle were more prone to stampede because they were more "jumpy and skittish" than domesticated cattle were. Longhorns could be provoked to stampede by any sudden noise, like a gunshot, a thunderclap, or even a broken twig, or a dropped cookpot being enough to set them off running.
When the Longhorns stampeded, the cowboys had several ways to try and stop the cattle, one was to ride and get ahead and turn them to the right (for some strange reason cattle don't want to turn to the left while running) and get them running in a tight circle, which would tighten until the cattle stopped. Another tactic was to just let them "run themselves out" and they would eventually stop and could be rounded up. Longhorns tended to stay together during a stampede unlike domestic cattle which tended to scatter.
Chasing after a stampeding herd was full of dangers like; the cowboys horse stepping in a hole or otherwise loosing its footing and throwing the cowboy off, perhaps into the path of the stampeding cows, or getting their foot caught in the stirrup and getting dragged to death. Cows could be lost, and some low level rustlers who were not brave enough to risk shooting it out with the trail cowboys, would stampede a herd, and gather a few cattle figuring the trail boss would assume that the cattle were "lost" and not stolen.
Although most stampedes were associated with Longhorn cattle, there were also Buffalo stampedes which were even more dangerous than cattle stampedes, because Buffalo ran straight ahead (their eyes were on the sides of their heads) blindly, and they could not as a practical matter, be stopped until they decided to stop running on their own. Also Buffalo stampedes might mean that 5,000 to 10,000 or more were on the move and they were generally bigger than most any cattle.
The Indians use to stampede Buffalo over cliffs, or into canyon walls to kill a lot of them quickly. There are also reports of Buffaloes running into trains and knocking them off of the tracks. A Buffalo stampede was a mighty movement of large heavy beasts, and best to stay away from.