Okay let's say you're pushing a ball, that ball itself can be composed of numerous more balls, 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$ and acceleration is $F/(m_1+m_2)$