I believe there are two contributing factors for this, both the role that they observe in the media and the parents reaction with their activities
For example , When you see children cartoon, you would often see a distinguish behaviour between the male and female characters, which might be perceived by the children as the way it supposed to be. Parents' reaction to their children when they play according to or in opposite to their gender role might also play an influence.