I've seen plenty of leg routines based entirely (or almost entirely)
on squats and deadlifts. My simple question is this routine is
balanced.
This question seems to depend on the assumption that it is a problem if an exercise routine is not "balanced", in that it trains antagonistic muscles equally. That isn't the case at all. Yes, leg routines that are based around squats and deadlifts develop hip and knee extension strength far more than they do hip and knee flexion strength, but there's no evidence to suggest that this is harmful.
Both in squat and deadlift the hip flexors shortens on the way down, i.e. they shortens in the same direction of gravity. I think this means they work but they are unloaded.
No, it means that the hip flexors do not do any work during these movements.
So, is there a risk to develop posterior pelvic tilt (strong glutes and weak hip flexors) if we only do squat and deadlift?
No, because the idea that muscular imbalances cause changes in posture is made up. It does not appear to have any evidence behind it.
Even mechanistically, there is no reason to think that strong glutes and weak hip flexors would tilt the pelvis, just because when a muscle is stronger, that only means it can exert more force on demand, not that it continuously exerts more force. So it's not like the glutes and hip flexors are constantly active, and in a tug-of-war against each other with the pelvis stuck in the middle. Muscles relax when they aren't in use.
I do not understand why many people perform lots of exercises for the hip extensors (glutes) and ignore the hip flexors.
The hip flexors just aren't important for most people unless they participate in a sprinting or kicking sport, or maybe some sports such as gymnastics or ballet, where demonstration of static active flexibility is valued.