In a nutshell and certainly not a complete explanation, North American railways (or 'railroads' if you're American) are controlled by CTC (centralized traffic control) when you see signals. There are other methods of train control where there are no signals, or 'dark territory', which require train crews to obtain written permission from the rail traffic controller (RTC or dispatcher) to occupy defined sections of track. This is obviously a very cumbersome method that requires a lot of radio communication between the train crew and the RTC and manually recorded authorities that allow a train to occupy a section of track. Because of this, you'll always see signals/CTC on heavily used corridors and the train crews are responsible to observe the signal indications to advise them of the upcoming track conditions and requirements for train operation (mainly speed of the train).
A signal can consist of a single light (aspect), two aspects, or three aspects. The combination of colours (red, green, yellow) and the display of the aspects (solid or flashing) provides information to the train crew on the upcoming track conditions and the speed at which to operate the train. There are many different combinations of signal displays that the train crew, more specifically the conductor, must memorize to properly instruct the engineer on how to operate the train. Of course, a signal with three aspects can provide many more combinations than a signal with two aspects, thus providing more detailed information to the train crew on how to proceed with the operation of the train.
You'll see three aspect signals, or 'home' signals, at the beginning of a signal plant (or interlocking) which consists of cross-overs or turnouts that allow trains to change tracks. The route that the train is lined for, either the straight route or the diverging route (lined for a cross-over to change tracks), is controlled by the RTC. The RTC does not actually control the signal display itself, but the routing of the track chosen by the RTC will cause the home signals to display the appropriate aspects. For example, if a train is lined for the straight route, the home signal would likely show a green-red-red (reading the signals from top to bottom) which is the most permissive signal indication and does not require a train crew to adjust their speed. If the RTC has lined the route to take a cross-over onto another track, the home signal will display a more restrictive signal indication requiring the train crew to adjust their speed. In fact, not just the home signal will provide this warning to the train crew, but usually one or more block signals further down the track as an advanced warning to the train crew of the upcoming track condition.
As mentioned above, the signal system operates using a 'block' system, or sections of track that have electric circuits running through the rails and these circuits are confined to only that section of track through the use of insulated joints at either end of the block. At each end of the block, you'll see a signal bridge or standing signal masts with either one or two aspects that provide information on the track conditions in that block.
If a block is empty, or not occupied by a train, the electric circuit is travelling in the individual rails and this provides information to the CTC system on how to display the block signal. When a train passes over the insulated joints (at the same location of the block signal), the steel wheels of the train will short the circuit in that block and 'tell' the block signal to display an all red signal, or a 'stop' indication to prevent trailing trains from entering this block until the block is cleared by the current train. This system was designed this way so that if a rail was broken, the circuit would be shorted and the signal would drop to red to prevent a train from entering this block and running over the rail defect. There are other examples of how the 'short circuit = stop signal' provides protection to trains from entering a block with unfavourable conditions. You'll see this in action if you're driving on the Gardiner or standing on a railway overpass. As soon as a train passes a signal, you'll see it drop to all red. The actual block signal display will not only take into account the condition of its own block, but also the adjacent blocks further down the track in the same travelling direction.
In the case of the VIA derailment, the preliminary report suggests that the VIA was lined by the RTC for the diverging route to change tracks. If the signals were working properly, the train crew would have left the Aldershot Station and passed signals informing them of the upcoming track condition and they would have known to reduce their speed to 15 mph. If the signal system was not working properly, they may have seen entirely permissive signals, or a 'clear' signal (green-red on the block signals, and green-red-red on the home signals at King Road) and they would have continued at full speed, or more likely continuing to accelerate as they left Aldershot Station.
We'll have to wait until the investigation is concluded before we know for sure. RIP.