B.,
Think about it, we tell them not to talk to strangers but the minute were caught with a stranger talking to them we tell them respond. Example, your son helps take small packages from the buggy to the counter and a man behind you says to him "my how strong you are, are you going to grow up and play football one day?" We wait for our child to respond with manners and all.......
It's difficult. We can't shun friendly conversation from others while in public yet we can't allow our child to run off and initiate conversation either.
He first needs to understand what a stranger is. Even a police officer is a stranger. Someone Mommy or Daddy does not know by name. Then as gently as possible explain the possibilities of what can happen if a stranger grabs him and takes him from you. He could stand you in a corner and pinch you all day and not feed you or let you come home to mommy or daddy, or won't let you watch t.v. or have your favorite toy. Scare them into understanding. It's difficult but necessary. Each time he's drawn back to in public with your motherly tone remind him, does mommy know his or her name? Only while mommy is with you to protect you can you talk to anyone. Over and over again, just like anything else they learn. Repetition is the key.
It is a scary world sister and just trust in the Lord to help guide you into teaching you little one the way. He's only two keep a close eye on him and constantly explain your ways. He'll catch on. And you'll be suprised what he'll understand.