How to reproduce
Summon a zombie with the nbt 'NoAI:1b'. Run 'execute on target run say hi', and notice that there isn't a target. Then attack another zombie (that's nearby) in survival mode. Run the same command within 5 seconds and discover the mob with no AI now has a target.
What to expect
The mob with no AI should not be able to acquire a target because it has no AI.
I know this also affects iron golems.
Can confirm in 1.20.3 Pre-Release 4, though this only happens for entities which share their target with other entities of the same kind. (like zombies, husks, and drowned)
[media]A correction on the issue, a proper command to use to reproduce this would be: