see karthik, i think there's a mistake in the 2nd equation because of the following explanation.
see man, when you are writing the equation on body A then you wrote F' - F = maa which is in accordance with the FBD of body A.
Now, when you wrote F'+F = mba then this isn't in accordance with the FBD because F' is on body A & not on body B. On body B, there's only one force which is F (or normal reaction) due to which there will be same acceleration on body B...
the correct equation should be F = mba.
plz correct me if i'm wrong....