To re-create:
This works in survival or in Creative
1. Have 2 Beds in an "L" shape next to each other (refer to pic 1)
2. Surround the beds in whatever block 2 high (w/ a roof)
3. then place 2 villagers in 1 bed and when set to night time one villager will sleep in the current bed while the other will path find to the closest one... Through the wall
Ps. I have seen that placing a roof over top the villager beds causes this more frequently
Please check if this is still an issue for you in 1.16 Release Candidate 1 or later.