If someday we get some kind of supergenius congress that can write laws that are unambiguous and have no loopholes then this won't be a problem. Until then there will be a constant back and forth between people who want to fund things with tax revenue and people who don't want to pay taxes about how to interpret the wording.
That's not the problem in this case. There is no one complaining about corporations avoiding their property tax or payroll tax. When Walmart collects sales tax, they're not finding some loophole that allows them to keep the money themselves instead of remitting it to the government, because that isn't really a thing.
The problem is specifically a structural defect in the way corporate income tax works for multinational corporations, because it's nominally a tax on profit. But unlike workers or land or customers, that isn't a thing with a physical location and that gives the corporations an unlimited number of ways to move it around so it ends up where they want it, which is in a place where they pay the least in tax.
It's not a matter of writing the law better. When you use that type of tax, the ambiguity is in the facts. If their global profit margin is e.g. 15% and you can't measure the fair market value of the things the subsidiaries in one country buy from a subsidiary in another with a smaller margin of error than that, they can shift all of their profits to wherever they want.
There is no reasonable way to fix it while still using that type of tax because it's not possible to measure the fair market value of everything with enough precision that they can't manipulate the outcome. You have to use a different type of tax instead, but then people don't do that and complain about the inevitable result.