The dog is probably doing what he has seen the farmer do when a cow leaves the barn alone. Many farm or ranch dogs somehow learn the rules and the system. Enforcing the system then becomes their #1 job. Ask any Border Collie why they do it?
“Cause it’s my Yob, Man.”