Goats move when there is no player nearby. This causes several issues and is considered a bug per the resolution of MC-47533.
To reproduce, spawn a few pigs and goats, then go into spectator mode. The pigs will not walk around, but the goats will.
Linked issues
Comments 2

Thank you for your report!
We're resolving and linking this ticket forward as a duplicate of MC-263152, as that ticket contains more detailed information and/or has already been triaged by Mojang.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
-- I am a bot. This action was performed automatically! The ticket was resolved by one of our moderators, and I left this message to give more information to you.
Can confirm. I have added steps to reproduce to this issue and to related issues.