What are the political factors that make it hard for countries to agree on a mechanism that will prevent tax evasion? The idea was discussed for so long and yet nothing was done to prevent it. What are the political factors that make it so difficult?
Because it only takes one country to defect and the defector stands to gain quite a bit.
Imagine there is an unprecedented global consensus to tax royalties on song lyrics at 15%-- all 195 countries in the world have agreed. If one country decides to defect and sets its rate at 10%, suddenly everyone in the world that makes money off of song lyrics will be setting up corporate entities in that country to own their song lyrics. The defector has a lower rate but a much, much larger base so it makes far more in taxes than it would with a higher rate and many fewer song-owning corporations operating there.
The remaining 194 countries can put pressure on the various tax haven countries not to defect but that pressure tends not to be particularly effective. Once you're a tax haven for song owners, there is substantial internal political pressure to remain a tax haven-- song royalty taxes are a substantial revenue source and song lyric owners are a large constituency. The other countries have to credibly offer some combination of carrots and sticks that outweighs the benefits the defector gains and there aren't a whole lot of carrots or sticks that really work.
In the real world, lots of tax avoidance involves taking advantage of highly technical differences in how different countries tax different things so lots of countries end up being tax havens in different ways. It's one thing to say "hey, don't give song lyric owners a break". It's another to say "hey, your approach to amortizing capital leases combined with some other country's approach to providing pollution tax credits creates the opportunity for sophisticated tax accountants to structure transactions in such a way that they avoid a lot of taxes". The former is relatively easy to understand and remedy. The latter is much harder to understand and messier. And since most countries have some tax law that is involved in one or another tax avoidance scheme, none of them are arguing from a position of purity. Plus, they may have good reasons for their tax policies-- one country may amortize capital leases differently because that is policy supports certain important native industries, the other country may find their pollution tax credits advance an important social policy.