They aren't losing money, they're spending it [on themselves].
The problems in taxation come when a company's spending isn't benefitting the area/country or its employees' taxable income. Buying offshore yachts to rent back, sinking money into highly-depreciative assets (eg company cars) that might not be taxed as employee benefits. There's a lot to unpack but the bigger you are, the easier it is to hide a few billion dollars from the national taxation service by hauling it off to another area.