In version 1.17.1 in the Java edition there is a bug with animals teleporting together with the player. For example, on the realm server, when I teleport to another player using the command, the animal stays at the starting point and does not teleport with the player. He '' comes back '' only after a certain period of time. It is very troublesome during the game, especially when you want to take your pet with you.
Is the chunk that your pets in unloaded?