Okay let's say youryou're pushing a ball ,that that ball itself can be composed of numerous more balls ,but but you only take the net force an the entire system i.e the ball as a whole .
Similarly, you can assume the blocks in contact to be a singular block whose net force is F$F$ and acceleration is F/m_1+m_2$F/(m_1+m_2)$