This bug is still happening in 21w11a, and seems to be caused when a bed is broken or obstructed but the villager who owns the bed doesn't see it happen. It's like there's a disconnect between the game and the villagers in terms of which beds are seen as claimed and which aren’t.
In the screenshot, the villager is as far into the house as he can go unassisted, due to being blocked by the torch.
Can confirm in 21w38a