When a train or a subway derails, its wheels accidentally leave the tracks. Train cars that derail can cause the cars behind them to crash.
Mistakes by engineers or flaws in the track can derail a train or trolley, sending it off the rails and sometimes injuring the passengers. You can also use the verb derail figuratively, to mean "hinder someone" or "divert a process from going in its intended direction." For example, terrorists might derail ongoing peace talks by blowing up a bus. The word comes from the French dérailler, "go off the rails."