sometimes i would find a unemployed villager in my walled up village and i checked that every villager has a job. For example, this happened to one of my farmers. the title explains the rest. Recently, I found out that this happens with beds. This makes the villagers not go inside any building, and that results in them getting killed by zombies.
Linked issues
Comments

Does MC-156031 describe your issue?
yes, but i'm noticing it more with the beds now because most of villagers died from zombies because the villagers didn't go inside to sleep.
Also, yes MC-156031 does describe the issue.
Is this still an issue in 1.15.2?