Babies are born without an ego. They only have the id - as defined by Freud - and operate on instinct, according to the pleasure principle. It makes sense to me that young babies are driven solely by the id, because they initially are not self-aware and do not yet have the desire for anything beyond their basic needs being met. There’s no self-awareness or higher-level thinking going on.
The shadow then grows as a layer over the id, or maybe a better way to put it is that it expands beyond the id. In other words, the id is at the root of all cognition.
Followed by the superego, which may happen when the child first becomes self-aware, or maybe it’s when the ego develops.
The ego is a symbiote that grows upward from the unconscious. It appears when the child becomes self-aware and is not fully formed until about 2-3.
This may be why people struggle with their superego… if the superego develops first, it gets a taste of freedom and thinks that it’s the ego, only to be shoved to the background when the ego develops. The superego is constantly trying to supplant the ego and get that freedom back.
As mentioned, the unconscious and the ego have a symbiotic relationship. The ego’s purpose is to act as a filter for the unconscious. Since it is not getting constantly bombarded by raw reality, the unconscious is freed up to do background planning and problem solving. It communicates with the ego via things like dreams, impulses, feelings, intrusive thoughts, intuition, etc.