I haven’t really thought about his much but in quite a few cases laws are attached to the nationality and not geographically bound. The US has an interesting instance of this where US citizens still have to pay taxes to the US government even if they live and earn money abroad.