Model Railway Level Crossing

The first thing is all those calls to "delay()" will have to go, or you're never going to detect the second switch in a timely manner.
Look at the blink without delay example to get a feel for the techniques you will need to do this.
Break down the light and servo sequence into a sequence of transitions and states.