Legal persons are considered to be resident for tax purposes in the country in which they are tax resident under the relevant country's internal law based on the location of the management’s offices, foundation and registration, etc.
Companies and entities not resident for tax purposes in any country must be considered as being resident where the head office is located. States, regional and local administrative authorities are considered to be resident in the country concerned.
If you are uncertain about whether the company or entity is resident for tax purposes in a particular country, you must contact the tax authorities in the country concerned in order to clarify the situation.
The OECD has compiled some information regarding tax residence in individual countries, which can be found here.