As with everything in international politics, there is no global standard.
But one thing which comes pretty close to an international standard is the European population and housing census regulation of 2008. Before this directive there were differences between how different EU countries counted their population, which lead to EU residents being counted double or not at all. This directive cleared up those differences to allow comparable population counts between different EU countries.
It defines "Population" as follows:
’population’ shall mean the national, regional and local
population at its usual residence at the reference date.
’usual residence’ shall mean the place where a person
normally spends the daily period of rest, regardless of
temporary absences for purposes of recreation, holidays,
visits to friends and relatives, business, medical treatment or
religious pilgrimage.
the following persons alone shall be considered to be usual
residents of the geographical area in question:
(i) those who have lived in their place of usual residence
for a continuous period of at least 12 months before
the reference date; or
(ii) those who arrived in their place of usual residence
during the 12 months before the reference date with
the intention of staying there for at least one year.
That means it counts all people who currently live within the borders of a state for at least a year or plan to stay for at least a year, regardless of their nationality and legal status.
People who are in a country on diplomatic or military mission would count as the population of that country when they are on an assignment of at least 12 month.
But this directive only applies to the EU. Internationally there are still large differences between who is considered a resident. Also, less developed countries often lack the bureaucratic infrastructure to do an accurate population count, so their population numbers are often just rough estimates.