The animals on your farm have their own will- especially those cute pets trying to escape and run around your farm exploring.
To make sure your pets stay within an enclosed area, simply drag the pet house within that area so your pets have access to it. That will give them peace of mind and stop them from trampling all over your crops!