Can we add attraction forces?
You need to multiply by four not by two. To see why let's draw the situation:
You are assuming the situation is as shown in the top diagram. So the two $M_1$s attract each other and the two $M_2$s attract each other. Those are the forces shown by the red lines.
But you also need to include the force between $M_1$ on one side and $M_2$ on the other. Those are the green lines in the second diagram. So the total force will be:
$$ F = F_{1-1} + F_{2-2} + F_{1-2} + F_{2-1} $$
Suppose we make the mass of each of the balls $M$, so if we combine them the total mass on each side is $2M$. If we combine the masses first then calculate the force we get:
$$ F = \frac{G(2M)(2M)}{d^2} = 4\frac{GM^2}{d^2} $$
If we calculate the forces treating the masses separately we get${}^1$:
$$\begin{align} F &= F_{1-1} + F_{2-2} + F_{1-2} + F_{2-1} \\ &= \frac{GMM}{d^2} + \frac{GMM}{d^2} + \frac{GMM}{d^2} + \frac{GMM}{d^2} \\ &= 4\frac{GM^2}{d^2} \end{align}$$
So the forces are the same.
This also applies to the example of the electrostatic force that you mention.
${}^1$ Strictly speaking the distances $M_1 \rightarrow M_2'$ and $M_2 \rightarrow M_1'$ are slightly greater than the distance $M_1 \rightarrow M_1'$ and $M_2 \rightarrow M_2'$ but we'll assume this difference is negligibly small.