Let me answer your specific doubts.
Aren't they action-reaction forces, so shouldn't they not be cancelled out?
Here F1 and F2 are action-reaction pair, so they have equal magnitude, and are acting opposite to each other.
But, will they cancel or not? To answer this, I consider your next question.
Aren't they equal and opposite, and act on different objects?
You are close to the concept. Whether any object(s) is(are) same or different depends on how we've defined the system. If you define the system as the (10 kg + 5 kg) masses, then F1 and F2 are forces in the same system, and hence they cancel out.
If you consider them as different systems, you have to take into account all the forces which are acting on each. So the 10 kg mass suffers F and -F1, whereas the 5 kg mass suffers only F2.
In the problem, first the whole system (10 kg + 5 kg) is considered to find out the acceleration a. In the this case, F1 and F2 are internal forces which cancel out (if you don't understand why, read about motion of rigid bodies to get a picture). Next, the individual masses are considered as one system each, to find F1/F2.