I've had the same issue multiple times. I believe this is the same bug that causes other entities (paintings, animals etc) to disappear: MCPE-21416
Mojang stated "We believe that random entity loss was fixed for most players in the 1.18.30 update by changes to how entities are stored in the world databse."
However, I've had Villagers, Paintings and Animals still disappearing in 1.20+. It might be related to going to other dimensions as you suggest, though I can't be sure. I'll need to do some more experiments.
I've had the same issue multiple times. I believe this is the same bug that causes other entities (paintings, animals etc) to disappear: MCPE-21416
Mojang stated "We believe that random entity loss was fixed for most players in the 1.18.30 update by changes to how entities are stored in the world databse."
However, I've had Villagers, Paintings and Animals still disappearing in 1.20+. It might be related to going to other dimensions as you suggest, though I can't be sure. I'll need to do some more experiments.