> And gravity seemingly treats all those bits as a single object.
It does not; but when you learned about gravity in school or wherever, you were only presented with scenarios in which it was valid to do so. Specifically, for Newtonian gravity, an object whose density is spherically symmetrical may be treated as a point mass at its center (w/r/t other point masses farther from the center than any point in the first object); this can be seen by integrating Newton's equation.
There's no reason to attribute this to special behavior by gravity with respect to "objects" which you identify. You could decompose a (spherically symmetrical) mass into several different spherically symmetrical "objects" and sum up their influence on a test mass, and the result is the same as if you had treated the original mass as a point mass. The hypothesis that gravity is "treating" the object one way or another now fails to distinguish all these possibilities; it's no longer physically meaningful.
At sufficiently large distances, or for sufficiently large ratio of large to small mass, the difference between, say, a planet and a spherically symmetrical mass is so small with respect to the main effect that it can simply be ignored.