Explanation:
Parents may treat their children differently dependent on their gender. This will directly impact their behaviour. Parents might only give their child "gender-appropriate" toys to play with, and tell them how they are supposed to act "as a boy" or "as a girl".
Children also learn easily by imitation. If they see someone acting a certain way, they can copy it. Who they choose to copy may depend on who appeals to them.
There is also some research which suggests gender specific behaviours are not purely environmental, and that there are some genetic factors that play a role.