The signals mean exactly what you think they do: They tell the drivers of trains when it is safe to proceed, and often, how fast is safe. Everyone knows that trains are heavy and can take a long time to stop. Trains must be warned in advance long before they bump into one another so they can stop before that happens.
Railroad signals vary in many ways, even on the same railroad or the same route. There are different classes of signals which serve different purposes. The two main classes are absolute and permissive. Absolute signals require a train to stop and stay stopped when they are "red." Permissive signals allow a train to continue on at a slow, controlled speed. In the United States, these signals are more-or-less identical in form and appearance, except that permissive signals have a number plate indicating the track mile of the signal. Railroad signals, especially in the United States, can have many varied appearances, even of the same class. This is because signaling has evolved over the past 100+ years and different railroads and eras have held different views on how best to do it. Because of this, signals have formed a part of many railroads' identities because are unique to that railroad. Your description of the two different forms of signals near you sound just like you said, an implementation detail (of tradition).
I am the author of the second link about signaling posted by alephzero above. If you still have any more questions, feel free to ask.