What is the doctrine of double effect and how can the doctrine of double effect explain why it is morally acceptable to reroute the train in the spur case but not in the fat man case?
What you are discussing here is what is called the "trolley problem." It was first postulated by British philosopher Philippa Ruth Foot in 1967, but has been discussed by many other philosophers. It is based on a thought experiment.
Imagine that you are driving a trolley and the brakes fail. Ahead of you, you see five workers on the track. You also notice a spur off to your right occupied by a single worker. Most people would argue that the better ethical choice in this situation is to save the five workers. The choice to turn off on the spur has a double effect of saving five workers and killing one. The death of the single worker is an unintended consequence that you as a trolley driver did not actively will.
In the second variant of the problem, one of the trolley passengers is a fat man. You have the option of pushing the fat man off the front of the trolley so that his body will slow the trolley down and save the workers. Morally, although the number of deaths are the same as in the spur problem, because killing the fat man involves actively willing his death, most philosophers argue (1) the two situations differ ethically and (2) the fat man problem constitutes a serious if not fatal objection to pure consequentialism.