If the driver had not stopped, the carriage would have been diverted onto a line where trains could run in both directions.
Network Rail said it had launched an investigation into the "serious signalling irregularity" at Cardiff East Junction.
No-one was injured during the incident on 29 December 2016.
The incident occurred after a section of track was reopened following resignalling and track remodelling work in and around Cardiff Central station.
The driver of the Cardiff Central to Treherbert service, noticed a set of points on the route were not in the correct position and stopped the train, during the incident at 08:46 GMT.
Shortly before, at 08:24, another train had travelled over another set of unsecured points -a similar fault on the same line - in the opposite direction.
When he stopped the train, the points were in "reverse" and it would have diverted the carriage onto the wrong track which would not have been picked up by the new signalling system.
Network Rail said it "acted quickly" to secure both sets of points.
A train almost veered onto the wrong track after a line fault at Cardiff Central, Network Rail said.