Pythagorean said:
Why do mammals (and probably some other vertebrates) seem to like affection so much? Is it an adaptation or a spandrel? If so, what is the adaptation(s) from which the spandrel emerged?
The statement is quite broad in scope. Good question though. In three words I would say "Friend or Foe" Assesment, discimination, and maybe throw in some aspect of sexual reproduction.
Are compliments included in there also, from anyone you meet, in which case, for example, a compliment from a stranger may be suspect as being sincere.
Such as a stranger saying to a little girl "Why, you are such a pretty thing!" wherein the reply may be " My mother told me never to talk to strangers." Some conditioning of acceptable close contact would appear to be part of the process.
Inter-species contact? You meet a dog on the sidewalk, either on a leash, or wandering on its own. You may want to pet it, with the outcome that both parties enjoy the physical attention. But before doing so, isn't the amygdala telling you " No, don't do it, there is a threat" while at the same time the cortex ( if that is the part of the brain doing it ) tells you " The animal needs help, and/or he is so cute." I am sure you have heard of cases where the "thrinking it through" has broken down, or not fully developed for infant, where swimming with the sharks, or playing with the gorilla, seemed at the time such a fine thing to do. ( Two zoo capers where one ended in tragedy ( for the animal) ).
Is it a contrare position to suggest that we as we mature, develop an envelope of personnal space around us, within which if anyone ( or possibly anything ) attempts to penetrate, we begin to feel anxious and somewhat take a defensive posture? That would be the limbic system at work, with the amagdala immediately accessing the situation and warning as a possible threat, with the other parts joining in with "yays" or "nays". Memory issued through the amagdala, may then say "Unknown, Still a threat" or "Familiar, Guards down", or "Sorry guys, Really really Familiar, enjoy the view."
I thought of replying just to get a grip on your question, so it may be not true to your request.
Being that a lot of mammals are a social animal there has to be some aspect to that as well.