In a creative world of mine, I have an area with one villager in each profession. But for some reason, a few of the villagers keep despawning. The Villagers that keep despawning are maxed level and have a name tag applied to them. But still, they keep disappearing.
P.S. These villagers are in a confined area, and they can't leave the building.
Related issues
Comments

Thank you for your report!
We're already tracking this issue at MCPE-21416, so I will resolve and link this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated. If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links: 📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki
I'm having the exact same problem but on a survival world! Max level farmers with nametags in an enclosed area are disappearing.