Will your firm catch you? Likely not if you are only working abroad for a few weeks, if you're doing it for longer, you'll probably get an email asking for clarification on your tax status (at best). At worst, they'll pull your VPN logs and demand that you get back to the states before you trigger some payroll issues.
Consider also that foreign employee of foreign firms have long traveled for business (well pre-Covid they did) and there is typically no work permit required for short/medium stays. In most places it just requires a typical tourist visa or equivalent when under 3 months.
Maybe this will be much more common and laws would change, but it's hard to see why countries would resist such residents; they bring their own job, they spend foreign money locally and they're no strain on the local social welfare system. Economically, they're just as beneficial as tourists and not as much of a risk as the average immigrant.
My country has a tax-treaty with the country I do most of my work for, and so I only pay taxes in one not the other. Without such a treaty I'd have to pay taxes in both countries and it would make it unviable.
Anyway, among other things, he said that doing any work inside US borders, if not on a work visa, is technically illegal. Like apparently if I'm on vacation in the US, and I pull out my phone to answer a few work emails, that's technically a visa violation, not that in that case anyone's gonna mind. IANAL TINLA. And of course you're interesting in jurisdictions other than the US.
So, yeah, I think the way to find out is find a lawyer in the jurisdiction you'd be wanting to work from, one who advertises themselves as specializing in visa issues.
Not sure about other countries but it's pretty much automatic in Germany for any job over EUR 55k (or something like that). Which is nearly all software jobs worth taking.
* EU work visas seem very hard to get
* EU software jobs seem to pay ~40% less than comparable American jobs before taxes (and EU taxes are more significant)--this leaves little slack for travel
* My wife's field is communications/marketing and she's pretty specialized to English/American-culture and the demand is quite a lot lower for her industry than mine
Then there's the hassle of long-term remote: figuring out taxes, selling our home, the logistics and costs of moving those possessions we're unwilling to sell to Europe, etc.
Work-from-home enables us to work from Europe for a few months at a time--we'll have to work odd hours (~2pm-9pm iirc) and we'll probably have to pay Europe rent and our American mortgage; however, we'll probably take most of our vacation during our abroad months so the odd hours will only apply for a few weeks and we can afford the additional housing cost (especially if we save for it during the months we're in the US). I think the tax situation should be okay since we'll be in the US for the majority of the year, but I need to find out for sure.