I crossed that border in both ways.
A special case nobody cited is that there's another narrow gauge track that ends at Hendaye/Hendaia coming from San Sebastián/Donosti. That is served by Euskotren, the basque railway company. This line allows passengers both ways.
People from the zone are used to this setup. As cited, that comes from a 19th century pact, minds were a lot different than nowadays (hopefully!). I don't remember if it's the same pact that dictates that an island in the middle of the Bidasoa river (which is used as the border between Spain and France) belongs six months in a year to Spain and the rest of the year to France.
Note that before the Schengen agreement, there were customs at each station. Having spanish customs at the spanish side of the border and viceversa makes sense somewhat. Since Schengen, there is no need for customs but some police random checks are usual at any France-Spain border. So some kind of jurisdiction issues may explain why this setup hasn't changed.
If you accidentally get off early, you have the Euskotren line as a backup, or alternatively you can walk the distance between stations, that's a 30min walk according to Google Maps. If you choose to use Euskotren, at Irun, the distance between broad/standard and narrow gauge stations is less than 10 minutes walking. The narrow gauge station is called "Irun Colón". At Hendaia the two stations are side by side.
At the other crossing points along the Pyrennees you need to be more careful, at Latour-de-Carol/La Tor de Querol the distance between border stations is a bit longer, maybe 5 kilometers, and at Portbou there is a mountain you would need to climb and descend to get to the other side of the border (there is a road, no need to hike). At Canfranc pass the french side is served by bus.