Two countries might consider you a tax resident at the same time in some cases. Thus, you could be asked to pay taxes on your total income in both nations. Fortunately, the majority of countries hold double tax agreements. These agreements usually provide the rules to determine which of the two countries should treat you as resident.
In a case of the tax treaty not providing a solution or when your situation is incredibly complicated, contact us to clarify your situation.