In this situation the villager pathfinds to the lectern and goes over rails in the process even though it is possible to avoid all rails with the only exception being the rail he is already standing on.
This behavior was confusing for me when trying to prevent villagers from pathfinding to barrels i used for storage. I thought blocking off the path with rails would be enough but villagers in minecarts just ignore rails.
Steps to Reproduce:
Recreate the following setup:
[media]Spawn a villager on the bottom rail
Expected Result:
Because there is a one block gap between the rails, the villager would still pathfind around the rain line instead of over it.
Observed Behavior:
The villager walks off the singular rail, and then pathfinds over the rail line to get to the work station.
Screenshots/Videos:
[media]
Notes:
Villagers (entities) not pathfinding over rails is WAI per MC-33359.
Linked issues
Attachments
Comments

Thank you for your report!
After consideration, the issue is being closed as Working as Intended.
Please note, that mechanics of the game may change between updates.
Things such as graphics, sounds, world creation, biomes, redstone, villagers, and animals may not work the same in current versions.
Full Version History – Snapshot Version History – The official Minecraft feedback site
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki