Apple would claim this is legal avoidance, not illegal evasion.
Tax law is the acts and statutes that bring it into existence, but it's also the case law that shapes it.
EU tax authorities tend to take a light touch approach - they'll tell you that they think you're non-compliant and how they want you to fix it. You can then tell them why they're wrong. They tend not to go to court against huge companies for anything other than blatant violations.
So, maybe the law is right, and Apple (etc etc) isn't following it correctly, but the enforcement of that law is wrong.