When a villager is attempting to path-find to a bed (or any path-finding), they can get stuck on various carpet/trapdoor/slab configurations.
1st test - carpet on slab: The village path-finds to the end of the makeshift corridor, but continues to jump on the bottom slab to try and get to the upper slab (ignoring the carpet). The villager continues to jump even during the daytime.
2nd test - The villager walks up to the trapdoor and stops (same happens with a double carpet). Either the villager should jump over it if there is space (and no carpet), or open/close the trapdoor. Although, the later may have unintended results with any redstone builds or farms (like certain iron golem farms...).
3rd test - Villagers can also get stuck on double-trap doors (similar to test 1). If the trap doors are aligned to the outside wall, the villager will continue to jump. If the trap doors are aligned to the inside wall, the villager will go to the trap door, face them and stop.
[media]
[media]
Related issues
Attachments
Comments

Hi just wanna add a bit more visual info to this issue that i believe might show the path-finding issue a bit more
[media][media]
[media]

We’re already tracking this issue at MC-96319, so this report will be resolved as a duplicate. If you have any additional information, we would appreciate you adding it to that report. In the future, please use the search function to see if your issue has already been reported.
Didn't find that one from 3 years ago when I searched, but I'll add the blocks affected there (going to work now, so it'll be 9 hours from now)