Children learn to imitate from what they see in their daily lives. In social settings, they don't know how to interact with other people, and so they rely on someone that appears on TV. They may imitate the way a cartoon character greet someone, or the way a person react at some inconvenience, and consider it to be a new social skill. This is a way for children to express their emotions and actions in real life.