Minecraft: Why did a villager brought to deserted village run away?

Solution 1:

I found out that it was because I let the villager out of the minecart at too great a distance of a door. For the second villager I simply put a door right next to the minecart, before releasing the villager, then it worked.

Solution 2:

My advice would be to bring him to the new village, and only let him run around right after sunset. Hopefully, he will sleep in one of the beds and stay there.