Kohlberg's theory of Gender Constancy basically argues that children don't start to deliberately acquire gender roles until they understand that their gender is fixed and won't (naturally) change. An important related idea is 'conservation' - the ability to understand that some fundamental property of a thing stays the same when in changes in a superficial way.
Here is the presentation from the lesson.
Here is Ernie Lawrence aged three and a bit, not showing much in the way of conservation:
Here he is last week, now four and a bit, capable of conservation in the simpler situation:
Edith Lawrence, aged two and four months, doesn't seem to have achieved Kohlberg's first stage, gender identity, at first, but her later answers are probably more valid, but she clearly isn't a gender expert:
Ernie aged three and a bit - gender identity, and signs of gender stability.
Aged four and a bit - gender stability more-or-less evident but gender consistency still some way off: