Why is the shoulder socket deeper than the hip socket?
It isn't. The hip socket is deeper than the shoulder socket. The shoulder socket is shallow to ensure a broad range of motion of the arm. The deep hip socket is for stability of the leg.
Both joints are enarthrodial (ball and socket joints), but the hip is more stable than the shoulder. This is out of necessity because the hip must support the weight of the body, while the shoulder does not have to. The cup in the hip that the head of the femur sits in is deeper than that of the shoulder holding the head of the humerus. This means less movement for the hip, but more stability.