Listening out for overbridges, tunnels, or the sound of running over an underbridge with a steel deck which would make a different noise aided knowing the location in the dark.
For a significant part of the 1980s I commuted to and from school over a few miles of the South Western main line, and after a few years I found I could tell quite well where I was in the dark just by listening; my father, commuting into Waterloo over a longer period, found the same. Cutting retaining walls, junctions/crossovers, and transitions between welded and jointed rail all helped; presumably curves would have done too, although there were no sharp ones on my route.
I certainly don't want to minimise the skill of drivers, who had much more route to learn, had to actually drive the train as well as knowing where they were, and had to get it right to a safety-critical level (of course they still do, in somewhat different conditions), but it sounds admirably difficult rather than amazingly impossible.
My two experiences of travelling on a steam locomotive footplate in the dark (in Poland in the 1990s, where the locomotives had powerful electric headlights) made me realise how looking at a bright fire destroys your night vision. Presumably the fireman wasn't much help for spotting signals at night, and the driver had to take care not to look at the fire. I did wonder whether loss of night vision might have been involved in some of those mystery accidents like Salisbury or Grantham.
Presumably a fast-asleep signalman was normally fail-safe, and trains would just stop until he was woken, but it was a half-asleep one that could be dangerous.
Do we have any preserved-railway drivers here who can comment on driving in the dark? Speeds there will be low, and there are only a few miles of route to learn, but presumably opportunities to practice night-time driving are limited.