I keep my villagers in 2x2 by 4 high rooms. Walls on all sides (including corners) and 4 blocks of empty space between the floors and ceilings. The only item inside the room is a single bed. There is an empty space for a single door (the space does not touch the bed), but instead of door being there, there's a workstation, then nothing directly above the work station (so that I can click on the villager to trade), and then above the space is back to being a wall/ceiling. I have this room copied multiple times, one for each villager.
When my villagers wake up in the morning, some of them spawn on top of their workstation instead of either of the 2 clear blocks of floor directly next to their bed. And because there's only a single empty space above the workstations, their head ends up spawning inside the solid block above the "window". Obviously they then die. My villagers have been doing this for months now. For the longest time I thought that hostile mobs were somehow getting to them, but it wasn't until just a few minutes ago that I finally figured out the problem because I literally watched a villager suffocate to death on top of their workstation with their head trapped inside the above block. I couldn't break the workstation in time to save them. And I'm still losing several villagers because of this bug, primarily librarians.
Related issues
Comments

Please keep your reports to a single issue and keep feedback to the feedback.minecraft.net or the feedback Discord. I have removed the portion of the description that was feedback unrelated to the reported issue.