I completely agree with CptJack here. Association by Scent. Is the best way to put it.
I wouldn't go as far as to say they smell you and go 'heeeeey its my friend'. but rather they smell you and think "im probably not going to get eaten..... "
And like any animal. A new scent is unfamiliar ground, so they are more cautious and weary of it. No different from a cat or dog really in that regard.