It generally happens due to algorithmic errors but also can happen due to human faults. Black box trading also known as algorithmic trading encompasses trading systems that work heavily on complex mathematical formulas and very fast computer programs to determine trading strategies. Hence these being very speedy systems sometimes a fault in the algorithm causes major drop or rise in prices of stocks which happens for a very few minutes.
The examples of flash crash are 2010 Flash Crash in the United States which lasted for around 36 minutes. It was a major trillion dollar crash in which Dow Jones crashed 998 points and recovered a large part of the loss.