The linking between villagers and their workstations/beds seems to be a random process.
Test-case
Have some unemployed, homeless (read: no bed) villagers in the world (blocked in a 1x1 glass box for testing purposes).
Place a bed in the world.
Observed facts
Beds are detected by the location of the pillow.
Villagers seem to have a centered detection "square" (needs further testing, might be cube) of ~ 32x32 for beds (workstations untested).
Placing a bed's pillow outside the detection range of all villagers means said bed remains undetected by any villager.
Expected result
The nearest, homeless villager will spot the new bed and bind to it.
Actual result
The nearest, homeless villager will spot the new bed, but the homeless villager that binds to it is picked randomly.
As a result, it is very difficult (if not impossible) to let villagers bind to specific sets of beds.
Obviously this affects "Trading Halls" which could arguably be unintentional, making this 'feature' a WAI. But even than this behavior is annoying when for example trying to make a nice, maybe segmented village and ending up with mad villagers that are unable to reach their bed/station as they picked one they can never see/reach again.
In my opinion, this behavior should be more controllable. For example by only choosing one of the villagers that can actually see the object by itself or, even better, determining the closest one of them.
Thank you for your report!
However, this issue has been closed as Working as Intended.
If you need help or have a suggestion you might like to follow a link below. (You might like to make a suggestion at the Minecraft Feedback Site.)
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki