You should read this post. It explains why it happens and how to prevent it.
Changing the trainer name breaks the tracker. You must change it to zero and edit the pokémon in the correct game. Pokémon from old gens, go and SWSH must be edited in SWSH, BDSP pokémon in BDSP, PLA pokémon in PLA, SV pokémon in SV. If you edit a pokémon from SWSH in BDSP and has a wrong tracker it will lose its ball.