You are kicked out at the front of the bed when there are walls nearby, or on the top of the pillow part of the bed when there are no walls, as opposed to the side. This is frustrating, as my beds are usually in corners, as with most people. The major issue, however, is that you can easily suffocate or be kicked out of the bed through a wall off of a multi-story building. This is only prevalent in the Java snapshot version 19w12b version, possibly other newer snapshots too. I hope this issue gets fixed. 🙂
Linked issues
Comments

This is one of the things I came in to report. Not only is the PLAYER exiting into walls, floors, or even on top of roofs, the villagers are, too!
Also, if they do, and there's another bed in the room on the other side of the wall, even though they always slept in their own bed before, after going through the wall, they think they have to go to the nearest bed in that room.
TEMPORARY WORKAROUND (if you have enough space)...don't put any edge of any bed next to any block!