Sometimes trains don't go where they're supposed to. And with so much bulk hurtling down the track, there needs to be a way to stop them from entering these unauthorized areas.
That's where a derailer comes in. As it's name suggests, a derailer derails the equipment that rolls over it.
As you might imagine, this can cause a lot of damage to the train that runs over the derailer. However, this damage is nothing compared to the destruction, injury or death that could occur if the train were allowed to proceed into the unauthorized area.
Derailers are installed where side tracks meet main lines, at junctions or other crossings, at an area where crews are working on a line, and anywhere approaching a drawbridge, dead end or other hazard.