Why does the gravitational force act as if all mass is at the center for a uniform sphere?
For a uniform sphere, symmetry ensures that the net gravitational force on an external point is equivalent to that of a point mass at the center, as forces from all parts combine accordingly.
Ref: Halliday & Resnick, Fundamentals of Physics, 11th ed., Chapter 13: Gravitation.