Minecraft wiki entry for Villager, associated text: A villager who has not yet traded can claim any job site block and changes its profession along with acquiring a new job.
Villagers who have made their first trade can claim a job site block only if the block is associated with their profession.
For a villager to claim a job site block in Java Edition, the block must be on the ground to allow the villager to pathfind to the job block. A job site block placed decoratively on scaffolding or a fence post, for example, cannot be found by a villager and no job assignment results.