Dogs don't pet each other on the top of the head, and neither should you. When a dog doesn't trust and respect you, they see this gesture as dominance. When you do it to a dominant dog, they see it as dominance and aggression, on your part. That is why they back away...