The "loophole" that Amazon has been using is nothing more than the EU single market, in all its glory, exactly as it was intended to be used.
When the EU and its predecessors were being set up, governments were all super keen to establish this sort of single market because they saw it as a way to allow their own home-grown champion companies to expand, by selling to people elsewhere on the continent.
You're contradicting yourself. Was the single market set up so that national companies could start selling to other EU countries with minimal red tape, or so that multinational companies could pick a country and negotiate with its tax authorities prior to setting up a "headquarters" which consists of a P.O. box? And if it was the latter, why is the Commission investigating whether the arrangements negotiated between various companies and the Luxembourgeois tax authorities constitute illegal state aid?