This is how it works for legal immigrants for many countries.
In SE Asia there's a whole cottage travel industry taking business and tourist visa holders on a quick trip out of the border in order to return to renew their visa (of course you can also pay for this service under the table).
This is not the case for transitioning from a temporary residence permit to a permanent residence permit, which is the best analogue to the USA’s Green Card. In most European countries, one does that within the country (and often within the same province one lives, at a regional office).