would drive me nuts also lol
There will be a set of one or more switches just short of the crossing. The train is pulling forward past the switch, waiting for it to be changed, then backing up onto a different track. Its either setting cars out on those tracks or picking them up (or both depending on the day).
Many plants don't have a single track long enough for all the cars they use. Cars are brought in on a single train but broken up into shorter units for loading/unloading.