Answer
The center of gravity accounts for the distance.
Work Step by Step
When leaning over, the person is picking the object up far from their center of gravity, which exerts a greater torque on their body. However, squatting with your back vertical leaves your center of mass far closer to the object you are attempting to pick up, causing a lesser torque to be exerted on your body as you attempt to pick it up.