Name tag is the only way for us (in survival mode) to keep our hostile mobs from disappearing.
Once a while we wanted to have peaceful mode on to forcefully kill all the hostile mobs (and passive-hostile i.e endermen and zombiefied piglin), or just to replenish our hunger bar. But if we did that, all our "Hostile Pets" are gone, reduced to atoms.
So I think this is should be considered as a bug. Nametagged Hostile Mobs SHOULD NOT Disappear in Peaceful Mode
Comments 2
For more information about this, see MC-5009, which has been resolved as Works as Intended.
Change request, not a bug.