Doesn't matter if a company is outside a country of tax residence of a freelancer. Within EU there is "reverse charge", with US there is W8 form, allowing freelancer to work for anyone in EU/US. But EU tax offices don't like freelancers in general, so they try to impose more difficult conditions to minimize their number.
It's actually good intentions. If you only have one customer, they push you in the direction of full employment to make sure you're not being exploited. Employment (in Germany) has health insurance included and your employer pays into your retirement fund. And of course minimum wage! Although that shouldn't be an issue in anything IT related.
I get the argument this was done for low-paid jobs to prevent worker's exploitation. However, it complicates life of highly paid consultants that e.g. work remotely as they are traveling around the world or get quick short-term highly paid gigs from all over the world (imagine Deep Learning freelancers). Legislation doesn't like that as regular payment to retirement funds has a priority (i.e. paying off current retired persons instead of saving money for one's advanced age).
Employees are often prevented by the same tax office to have two comparable jobs at the same time; the only way that it could work is to become a freelancer.