転居 and 外泊: changing residence and spending a night away
Compare moving to another town for work with staying at a friend's house, distinguishing a change of residence from an overnight stay away from home.
Moving one's residence elsewhere
転居 (てんきょ) means changing one's residence. 「仕事の都合で春に別の町へ転居した。」 says that the speaker moved to another town in the spring for work.
仕事の都合で gives the reason, 春に gives the time, and 別の町へ gives the place moved to. Read the past action of relocating the residence to another town.
Spending a night at a friend's house
外泊 (がいはく) means spending a night away from home. 「友人の家に泊まり、久しぶりに外泊しました。」 says that the speaker stayed overnight at a friend's house for the first time in a while.
友人の家 is the place of this overnight stay, and 久しぶりに indicates the gap since the last occasion. It neither means the first overnight stay ever nor establishes the friend's house as a new residence.
Changing residence and staying away overnight
The 転居 example reports moving one's residence to another town. The 外泊 example reports spending a night at a friend's house away from home.
The place of an overnight stay alone does not establish a change of residence. Read the time and reason for the move alongside the place of the overnight stay to distinguish relocation from staying away overnight.
Does staying at a friend's house with 外泊しました mean moving there?
Show the answer and why
No. It reports spending a night at the friend's house, without establishing the change of residence described by 転居.

