I go to a lot of quieter areas. The problem with finding toilets closed is that people will just choose to go around them. Over time, this can leave a big mess.
TBF by the time they've got to a toilet to find it closed, it probably is not much of an actual choice to go nearby. There's only so long that bodily control lasts.
Yes, public toilets should be mandatory. If that means charging for them - with possibly an override scheme for those with medical conditions - then so be it.
An alternative, in some areas might be to pay businesses an allowance to open their toilets for public use, regardless of whether you are a customer or not. Or a scheme that requires them to open their toilets but for a small fee per person, as above.
With a sign in the window showing there is a toilet for use inside.
There are some fantastic self cleaning public toilet cubicles that could be used in more remote areas. Again with a fee scheme.
In short, there feels like multiple ways this could be tackled. Not for the first time I despair at how unwilling governments (maybe voters) in this country are to try something new in the spirit of public betterment.