Not sure for Thailand but I've heard the same for Japan.
The counterfactual would be that if this were possible, every foreigner in Thailand would be made an employee of a company in Ireland or something to avoid dealing with visa issues (or tax issues )
You can't licitly work for a foreign company from Japan without a work-capable visa, though Japan won't work too hard to detect and penalize this given that you're keeping your nose clean. I'd strongly recommend keeping it legal; it starts to matter a lot more as you put down roots and get asked "So what were you doing last N years?" by various authorities.