You were bitten by a dog as a kid, and dogs still frighten you. The lady working at the deli reminds you of your third grade teacher. The guy next to you on the plane looks like your college buddy Stan, so you start telling him the kind of obscene jokes Stan would love. But he's not amused.
This tendency to relate and equate past relationships with current ones is normal. In order to make sense of new information we look to a related template already on file and examine similarities and differences. For example, based on your experience with your wise, gentle and physically limited grandmother, you would tend to treat all elderly women in a manner similar to her initially. You might see one at the corner, and with arm extended and a big smile you offer to help her across the street, only to find she's neither physically limited nor gentle. Whoops.
Part of the work of therapy is exploring this very issue. We all transfer our templates from prior relationships onto new ones - and from the first phone call you begin transference with your therapist. The structure of therapy encourages it.
Therapists typically maintain a stance of objective neutrality. This means they usually don't share a whole lot of information about their personal lives or their privately held thoughts, feelings or judgments about the material you bring up. This varies from therapist to therapist, of course, and different psychological theories do this to a greater or lesser degree. But generally speaking, the therapist is a blank canvas. They do this because what you transfer onto them says something very important about you.
John (a fake client) has been in therapy three months and comes into his session looking agitated and suspicious. I ask him how he is and he answers with "oh, wouldn't you like to know?!" It turns out John was laid off from his job, and he's assuming I will be angry with him. He entered the session preparing himself for the lecture I would give him about his failure to accept responsibility. By further exploring this, we find that he experienced his dad as critical and unempathic, and assumed I would respond the same way. In fact, I felt sadness and compassion when I heard his news, and I shared this with him. By pointing out this inaccurate assumption, John was able to understand why he tends to withdraw whenever he gets bad news: he expects other people to criticize him like his father used to, even though this has rarely proven true. He transferred his father's response onto me.
It seems we start with a limited number of templates at our disposal, the most powerful ones coming from our early caregivers. We tend to assume most new people will respond in ways similar to these original templates, even when there is evidence to the contrary. Some of the most important work in therapy is examining these old molds to see how they've shaped our relationships and our development. Challenging, difficult growth comes when we try to develop new templates.
Not all dogs bite. Not every old woman wants our help. Not everyone responds like John's dad. Therapy and the therapeutic relationship is one of the best places to check our assumptions. We might be playing according to rules that no longer apply.