Let say I am a junior SWE in EU. I incorporate in Estonia and issue my employer with an invoice from said company. That company pays for my house, my car, my dental service and whatnot, and what's left I take as a employee salary.
I pay local tax for that salary, but that's only a fraction of what I've billed my employer.
There's also the CFC rule, which means that within the EU, if you control a foreign corporation, your country of tax residence can tax undistributed profits.
Often tax offices don't bother and you might not get caught, but 'not getting caught' is not the same as it being legit.
Until you get audited by your local tax authority who rules that all of that is disguised salary, or the Estonian tax authority says that that's technically (taxable) profit being paid to the director.
If you're currently doing this, I suggest throwing yourself at the mercy of your local tax authority with the help of a lawyer and an accountant, as it's possible they'll show some leniency if you go to them first and not add penalty fines in addition to needing to back-pay the tax and late payment fines.
You've got to get up pretty early in the morning to fool The Revenue.
You'd be far better-off jumping between countries to leverage the 30% ruling/Beckham Law/HSM tax arrangements if you can.