Passing through a station with toilets is one thing. Getting out is another. Trains just don't hang around while passengers go to the loo. If you have a connection to make elsewhere then you may not have time to wait for the next train.
As someone with health issues I prefer to travel on trains with loos. I do regularly travel for 40 minutes on trains without loos. However I make sure I've been in advance or feel confident I won't need to go during the journey. Should the train get stuck for several hours that would not be good. Not happened yet thankfully.
As for stations, many unstaffed stations have no loos or they close them for most of the day. I'm also not so keen on councils who have disabled toilets but don't use the radar key system. This system allows users access to otherwise locked toilets. Oxford Council are guilty of this. It's ok in the city centre as they open a toilet purely for night use. Not so when you are out in the suburbs. Not everything happens in the town centre. People do spend time in other parts of the city. I think Sunday they were also locked during the day.
Sent from my HUAWEI U8815 using Tapatalk
And looking on National Rail's Station's Made Easy, many stations are unstaffed at night (anytime from around 7pm onwards). Even when stations are staffed, the toilets are often locked at night (although I don't know if they would give you access to one if you asked them nicely?).
Of course, all of this is only relevant if the stations actually have toilets. There are loads of unstaffed stations on the network. Just looking at one of my local lines, Sheffield to Lincoln: There's only Sheffield, Retford and Lincoln that it staffed all day every day (more or less). Worksop has staff, but they arrive at 7am and leave at 5pm Monday to Friday, and 13:45 (I think) on a Saturday (no staff on a Sunday). According to Stations Made Easy, the toilet is kept locked and needs a key from station staff. I've never actually boarded or alighted at Worksop though, so I don't know if this is the case.
Bearing in mind that Worksop is an interchange, so people may have come from Nottingham and be changing trains to the Sheffield- Lincoln line, and the journey times would be well over an hour if you were changing trains and going to, say, Saxilby or Darnall, toilets are definitely needed.