Imagine a scenario where you are a tax resident of country A, but you earn income in country B. Which country has the right to collect tax on your income? This issue is resolved by international treaties.
Without a double taxation avoidance agreement, both countries could claim the full amount of tax on the same income. This would lead to the worker paying a huge percentage of their earnings in taxes to both countries.
The country of residence fully exempts from tax the income that has already been taxed in the country where it was earned. The worker only submits proof of tax paid abroad.
The country of residence calculates tax at its own rates but subtracts (credits) the tax already paid abroad from that amount. The worker pays only the potential difference if the domestic tax is higher.
In situations where there is no signed agreement, the worker is at risk of paying the full tax amount in both countries. First, the foreign country will take its share, and then the domestic tax administration will claim tax on the same already reduced amount, not recognizing the costs paid abroad.