How can I be absolutely sure of myself when I am solving problems using Newton's Second Law?

Newton's second law says that the net force acting on an object is equal to that object's mass times its acceleration.

Just be sure that you know which net force you are calculating, i.e. which object you are applying Newton's second law to. If Fnet refers to the net force on mass 1, then it is given by m1 * a1, by Newton's second law. If it refers to the net force on mass 2, then it is given by m2 * a2.

If you include both masses (and assume the rope has negligible mass), then you are calculating the net force on the system, and have to be sure to multiply this mass by the acceleration of the system, which is....???