What if several objects exert gravitational forces on one another?
The Principle of Superposition: The net force on an object is the vector sum of the individual forces on the object.
In Case 4 shown in the picture, for instance, the net force on the small blue mass in the center can be found by determining the force due to each of the four red masses separately, and then adding the resulting vectors. The red masses exert forces on one another, but those do not matter - all we need to worry about is the force that each red mass applies to the blue one.