It has nothing to do with lag. When mob (every mob) spawns, if you hit it from the moment it spawn until like half a second after it spawn, it will stay yellow, only after will the claim work.

I used to grind at Copperbell mines on doblyns where its super crowded and all doblyns were pretty much camped, and that always happened.

At last, i finally got used to waiting 1 second before i hit it once it spawned. you have to be really fast to make that bug happen