The ego develops in the early childhood (2-3) and operates on the reality principle, balancing the demands of the Id with the constraints of the superego.
The superego emerges around age 5, internalizing societal rules and expectations from the same sex parent. It operates on the morality principle, striving for perfection and avoiding guilt.