My villagers spawn with name tags all the time. What can I do (Minecraft)?
Bedrock or Java?
Bedrock
Villager - like all other friendly mobs - can't despawn anyway. So giving you a name tag doesn't change anything.
In the Bedrock Edition - which you play - there's a bug that entities are deleted if they cross a chunk boundary during a save. Maybe that happened to you too.
Bug report: https://bugs.mojang.com/...MCPE-21416
The only solution to this is to prevent them from crossing chunk boundaries.
Build your villager farm in a single chunk, or draw walls on the chunk boundaries so the villagers can't go from one chunk to the next.
Happened to me today too.