Sure, I will try as best as I can:
tldr; VAT always has to be collected based on the customers location. But, there are two exception: when the customer is a business located in another EU nation or when the customer isn't located inside the EU. In that case, no VAT needs to be charged. Whether a customer is a business (in VAT perspective) is determined whether he provides you with his VAT ID, which you first need to verify.
long version; The core concept of Value Added Taxation (VAT) within the European Union is that the consumer of any product or service has to pay tax on it. This is usually handled transparently for the consumer (prices always have to be inclusive of tax): the seller needs to collect theses taxes and send a report to their local tax authorities at the months or quarters end (depending on the size of the sellers company). The VAT rates can be chosen by the individual EU member state and the rate to apply depends on where the sale happened. For decades the question of "where the sale happened" was easy to answer: think of a local shop in Denmark. The shop is located in Denkmark, where there is a 25% VAT rate, and the sale happened inside this shop. The shop owner would thus just collect 25% on all the sales and pay them to the tax authorities of Denmark. Life is so simple in traditional businesses.
If we would stop here, there would be one problem: when there are multiple processing steps, VAT would have to be paid multiple times. For example, in the furniture industry: first, wood would be chopped and sold (so VAT is paid on the raw wood). Second, wood would be cut into planks and the planks are sold (VAT paid again). Third, the actual furniture might be produced and sold to whole sale businesses (again VAT is paid). And so on, soon we would pay more VAT than anything else in our value chain, thus businesses have to be excluded from paying VAT. In general, this is handled in the following way: any seller always charges VAT and hands out a “VAT invoice” which has to follow specific rules to ensure that these are verifiable unique. If the buyer is a business owner he can then go to the local tax authorities to reclaim the paid tax.
But, local in that perspective means the tax authorities of the nation where the sale happened. Thus, if you shop all over Europe you would need to visit multiple different tax authorities to ask refunds for the individual purchases. So, the EU thought about one more rule to make that process easier: if you shop outside your home nation, you show the seller your VAT ID (which he has to verify) and then doesn’t need to charge you VAT on your purchase. But remember, only in other nations, within your home nation the system continued to work as before.
That system actually worked well for decades. But then the internet appeared, and some businesses tried to save some tax by declaring that their shop was the place where the sale happend. And - suddenly - many online shops where hosted in Luxembourg where there is just a 19% VAT rate (Amazon and Apples iTunes, for example). Well, governments didn’t like that so they declared: in e-commerce the sale always happens at the place where the customer was at the time of purchase. (Nobody knows how the legal guys thought one would determine the place where the customer was at purchase, but most businesses just interept this law as “whatever address the customer provided me with” and that seems fine and common practice).
One positive note to finish that post: VAT is one of the very few tax concepts that are regulated on an EU level. EU member states are only allowed to choose their VAT rate and declare exceptions for very small businesses. (In contrast to for example, income taxes or capital gain taxes, this VAT stuff can actually be considered "simple".) Some more cautionary note: I'm not a tax consultant, just a business owner for nearly a decade.