Some of us are old enough to remember 'non-corridor' trains with no toilet facilities. It was legal to run trains without toilets then and it remains so now.
Train companies obviously prefer to run trains with functioning toilets. However (often due to vandalism) there is sometimes a situation where the only train available to run a service is one without any usable toilet on board. (Generally that will only occur when services are operated by the smaller trains, of between one and three carriages, which only have a single toilet on board. Intercity services normally have plenty of toilets, so at least some will be functional).
I ran a railway station for 4 years but I can only recall a handful of occasions when it was necessary to operate a service using a train with no toilet. On every occasion I ensured that passengers were warned in advance (so that they could use the station facilities prior to travel). The train conductor was always instructed to offer customers the opportunity to use the facilities at the only staffed station along the route used by most of those trains but we always hoped that they wouldn't do so because a short delay on that service could lead to big 'knock-on' problems later.
Train companies face heavy penalties if train services are delayed. A colleague of mine once held a mainline service for 2 minutes to enable customers from a delayed local service to connect with it. The 'knock on' charges for that 2 minute delay cost the company over £5000. Most passengers would applaud the policy of penalising train companies for delays but it does mean that many connections have to be missed, and also that train operators will try to restrict the number of 'comfort stops' on trains with no toilets.
Chris