In every part of Thailand I've been to outside BKK, there's a gas station almost every few kilometers on every major road. Almost every gas station has a public restroom that's open 24/7, unattended. The ones that don't have a public restroom are typically right next to a string of restaurants that have a restroom you can use during the day for free if you ask.
Not that I don't believe you, but don't take that to be a common occurrence in Japan at all. By and large, Japan is a safe haven of clean and comfortable public restrooms. There are always exceptions, of course.