Exactly.
The culture of the judicial system works in a wholly different way in developing nations than in the West. They don't practice laws like we do. When you cause trouble in Thailand, they'll find any law you might have broken, just to get you, but when you don't cause trouble, most of the times you're fine, even if you might be breaking the law in official terms. I heard it's the same in China.
Sure, it's a risk, but please tell me why all these co-working spaces everywhere are filled with foreigners without work permits and growing rapidly.
Remote working is a new reality, and it would be highly counter-productive for these countries to start striking down on people working there. Every single foreigner I met in Thailand was working on projects either focused on their own country or internationally, thus not threatening local jobs. In reality, many of the Thai learnt from the foreigners that'd teach them about their tech stacks. That's exactly how they're building their own startup scene in Bangkok now. Learning from foreigners.
I'd argue it may increase a developing nation's level of innovation to have remote workers around and governments should embrace this new reality asap.