Rails protect people from falling... off porches, out of bed, down the steps, out of a tree house or gazebo.
Rails are generally used to keep a handle or an precaution on climbing stairs or setting barriers to prevent accidents of falling over.
They are generally made of metal material. They may be coated with paint to give a nicer color or to prevent rusting. Other alternative materials that may be used is wood.
Rails may also refer to the tracks that trains go on.
If someone is said to go "off the rail", it means that they lose control and starts behaving in a way that may be deemed unacceptable, or it may also mean that someone has lost all sight of reality and gone into a world that is seen as not real.