The positive x axis is to the right. See the figure below.
In both cases the acceleration of the system of the two masses will be the same in absolute value, but having a negative sign in front of it for case b).
`|a| =|F|/(m1+m2) =20/(2.5+5) =2.67 m/s^2`
In case a from the total applied force one needs to subtract the inertia of mass B to find the force on mass A. (This can be seen by writing the total net force on the x axis for mass B as being zero)
` ``F_(BA) -m*a= F `
`F_(BA)=F+m_B*a = -20 +5*2.67 =-6.67 N`
Since action = reaction (in absolute value)
`F_(AB) =-F_(BA) =6.67 N`
In this case from the applied force one needs to subtract the inertia of mass A.
`F_(AB) =F+m_A*a =20 - 2.5*2.67 = 13.325 N`
Again since action = reaction (in absolute value) we have
`F(BA) =-F(AB) = -13.325 N`
The interaction forces are different in the two cases because the inertia forces that are abstracted from the applied force are different in the two cases. In case a) we need to subtract the inertia of mass B, in case b) we need to subtract the inertia of mass A).
As said before the acceleration of both masses is the same in both casses (except a sign in front of it).
If we take case a) `a =2.67m/s^2` . If only mass A is present
`F= m_A*a =2.5*2.67 =6.67 N`
The net force if mass A were alone is exactly the push force it receives from B).