I believe most countries if not all, consider time in government service as time in residence Amethyst. The military being the most obvious one.
Another factor with retiring in another country is taxes. Specifically income tax. There are some serious ramifications to that as well.
Canadians for example are taxed on their world wide income if they are 'deemed to be resident' in Canada. For the tax department to 'deem you resident' only requires as little as maintaining a bank account in the country or owning a piece of property. When I left Canada to live/travel elsewhere, it took me 3 years to achieve 'non-resident status' in Canada and stop having to pay income tax there. Once they gotcha they don't wanna let you go. I had to move everything 'off-shore' (we won't go into that), sell property and close all bank accounts.
Once out though the trick is to never become a 'resident' anywhere else. Do that and you fall into limbo. No one to tax anything. All legal but not that easy to do.
Unfortunately, you can't stay in limbo forever. Once you are old enough to collect a government pension, you have to declare that income and file tax returns in your home country for that income. I now have to declare income once again in Canada on my 2 Canadian government pensions. But they don't total enough to require me to pay any tax after I use the exemptions I am entitled to. Something like 40% of Canadians pay no income tax!
When we moved to Canada after my wife retired (52), she had the choice to either pay income tax in the UK or in Canada. The exemptions and tax rate in Canada were lower and so she opted for paying tax in Canada.
Which brings us to another biggie regarding tax. Retirees from the UK who retire overseas have to consider what country they willl retire in as it may result in them losing all cost of living increases in their pension.
While Canada will pay government pensions to any country you want and those pensions are index linked, the same is not true for UK state pensions. If the UK does not have a tax treaty with a country the pension you receive when you first apply for it is FIXED at that amount forever. The ridiculous thing is that it is generally the Commonwealth countries to which this applies.
So when my wife starts getting here UK state pension next year, whatever amount she gets in GBP will be fixed at that amount forever. If she chose to stay in the UK or live in the USA or any one of dozens of other countries, it would increase every year according to the cost of living index in the UK. No fairness in that is there. Some people maintain a UK address (of a relative) and lie about not being resident in order to keep their pension index linked. They have it paid into a UK bank and just use ATMs to withdraw in whatever country they are actually in. That is of course illegal and I am not suggesting anyone do it.
Governments don't always seem to think about what makes sense or is fair. Retirees living overseas aren't voters any more. That they lived all their working life in a country and contributed for all those years just like anyone else doesn't matter. I consider the UK pension problem (for retirees) one of the biggest cases of punishing retirees there is.
That's why we feel no compunction in taking advantage of another UK pension situation which exists (but is due to be taken away in a year, we will just make it under the wire). They have a 'spouse pension'. It was intended to provide a housewife with her own pension after a lifetime spent as a housewife who paid in no National Insurance contributions of her own. Canada's OAS pension based only on residency does the same. It made sense. However, it was yet another case of government not thinking something through properly.
To qualify for a 'spouse pension' you need to be married to someone who will qualify for a UK State Pension at the time that they claim their pension. Some years ago they even changed the rule to apply to any 'spouse', not just women. Can't have sex discrimination can we.
So I will be eligible to apply for a spouse's pension which is 2/3s of whatever my wife's State Pension will be. Anyone who married a Brit who will claim their pension before they do away with it next year, can do the same. You do not have to have ever even stepped foot in the UK! That means they are going to pay me around $8k CAD per year. We see that as making up for freezing my wife's State Pension. You can see why they now want to stop it.
Lesson here, marry a Brit quick who will claim before the cut-off date. But you've got to be 65 or older yourself.