Bad guys are almost always portrayed as strangers. Remember, a stranger is someone who is not known by the child. A friend of parents, a friend of the child's friend or a neighbor can be a stranger. And a stranger can be a good guy or a bad guy. Some bad guys are attractive and act nice and friendly.
Some bad guys play tricks on kids.
Teach kids that a bad guy is someone who asks them to violate family rules, e.g., someone who says they don't need permission to accompany them. The code word should remain a secret and be changed should others learn of it. Teach them types of situations to avoid. It's not good enough to tell a child to avoid strangers. The single most effective means of protecting your children is communication with your child.