Most dogs seem to know bad people right off, so I’m sure the feeling is mutual.
I have noticed the same about dogs. When I got a blind date with the girl I later married, she had a small protective dog that had driven off several suitors. When I knocked and she answered the door the dog flew at me snarling and growling.
Suddenly it stopped put it’s butt on the ground and looked at me with this “HI! I LIKE YOU!” look on it’s face. From that moment on the dog and I were the best of friends. I also married the dogs owner. Best thing I ever did. 49 years of bliss till my wife passed away.
I was raised with the belief that dogs don’t like bad spirits either and will keep them away. Funny thing that the muslims believe that dogs prevent “angels” from entering a home.