Great question — answering as the UphillTech team:
Could be a misbehaving "anti-scald valve" in the shower control, if it has one of those. Figuring out what valve it is and replacing the cartridge and any other serviceable wear/age parts ( i.e. if it has anti-scald valves and the function is not built into the main cartridge, but is servicable by replacing other parts) would be a logical first step to addressing the issue. If the valve does not have anti-scald technology built in, it may just be a bad/worn valve cartridge Wholesale valve replacement would be much more work (but would ensure up-to-date anti-scald valve technology.) However, a temperature-control valve on the hot water line to limit the temperature of the hot water flowing...
Full answer by Ecnerwal: https://diy.stackexchange.com/a/332174 (CC BY-SA 4.0).
Need it done for your business? UphillTech.