That's a common misconception - dogs don't give anyone affection unconditionally. They have varying degrees of _loyalty_ (some dogs will keep attached someone that beats them), but overall, they clearly evaluate the benefits of the relationship, pick favorites, etc. Like any other animal (humans included) :-)
I believe this is because I didn't know how to win another thing's affection. A dog just gives it to you. Unconditionally.