Tax residency determines which country has the right to tax your worldwide income and gains, and under which rules. It is distinct from nationality or immigration status: you can be a citizen of one country while being tax resident in another. Most countries test residency using days of physical presence, the location of your permanent home, and where your centre of vital interests, such as family and business, lies.
A widely used benchmark is the 183-day rule: spending more than 183 days in a country within a tax year often makes you resident there. The UK applies a more detailed Statutory Residence Test, Italy looks at registration with the resident population and habitual abode, and Germany, France, and Spain each combine day-counting with home and economic ties.
Residency matters because resident and non-resident taxpayers are treated very differently. Residents are usually taxed on global income, while non-residents are taxed only on income sourced within that country. The US is unusual in taxing its citizens on worldwide income regardless of where they live.
Where two countries both claim you, tax treaties provide tie-breaker rules. See double taxation and tax year for how these interact.