I think what you're doing here is confusing railway signals with traffic lights, which is understandable if you don't know anything about railways as they look generally quite similar. They are, however, quite different.
To understand why we need signals, we have to go right back to the beginning of the railways. At this point, they were like roads: anyone could get hold of a train and run it. Every train had to be proceeded by a man with a red flag. If two trains were on the same line, one had to go back to the nearest crossover and allow the other to pass.
As speeds increased this became unworkable as trains couldn't stop within the distances the drivers could see (this is to do with the fact that the locos wheels are steel and the rails are steel, so there isn't as much friction as between a road and a tyre), so they decided to split the railway into blocks controlled by signal boxes. The signalmen had to leave a specific length of time between trains to allow the preceding train to get to the next signal box. This was known, for obvious reasons, as the time interval system of working.
Unfortunately, as before, this was also found to be unworkable: if a train broke down in the section (and many did, in those early days), a train would only be a few minutes behind it. This lead to quite a few accidents, so the concept was changed. Instead of leaving a time interval between trains, a space interval was left instead. To achieve this, the line was split up between signal boxes and each section was called a block. Only one train could be in a block at any time (although some freight only lines and platforms used permissive block, whereby a train could enter the block while the train in front was still in the block), and this was achieved by the signalmen communicating by electric telegraph. If you had a clear signal, you had a clear run until the next block, and you could only run into the block if you had a clear signal.
Later, colour light signalling came into operation. This works in pretty much the same way as the block signalling outlined above, but the signals controlling straight sections of track are automatic (although there were some colour light signals controlled by the manual signal boxes, especially if the signals were a long way away). Junctions still require the input of the signaller.
So you can see that railway signals are different to traffic lights: they're needed for every stretch of line, not just to control traffic flows around junctions. You may want to read a book about signalling for more information, there are lots of them around.
HTH,
Matt