There are a few reasons Minecraft players may choose to trap villagers, but one of the most common ones is to facilitate massive trading or create individual trading cells. This is done to avoid searching for villagers and wasting time.

Fortunately, the capturing and moving of villagers doesn’t take much effort. Since their pathing mechanics can be impeded by certain doors or objects which they are unable to interact with, villagers’ movements can be easily blocked.
However, in order to keep the villager’s designated profession, they need to remain close to their essential blocks. The correct trap will allow players to trade with villagers without them losing their profession.
Minecraft: Ways to capture and keep villagers in place
Read More: How to make a Charged Creeper farm in Minecraft 1.17