It doesn't seem to me that a railway semaphore describes a semaphore better than any other generic signalling object, like a flag or a stoplight. Even something like a keyring (people take keys off the ring to access locked resources, then return them when they're finished) is more descriptive. So why is a semaphore called a semaphore?
It's the metaphor that the creator of the idea proposed.
The idea was proposed by Dutch computer scientist Edsger Dijkstra in the early 1960s.
He describes the concept as:
Go to sleep, we'll wake you up again when you need to continue.
This sounds to me like a metaphor for a train driver approaching a semaphore and stopping until being allowed to resume.
He says in the paper:
From now on I will call the logical variable that prohibits the machine from continuing on as seinpaal (or semaphore)
If created by an English-speaker, they might have chosen something else. But for a Dutch-speaker in the 1960s, this analogy must have made the most sense to describe what the idea was.