(a) The engine is fixed to the body, so the torque it applies to the main rotor is an internal torque of the system (body + rotor); by Newton's third law the rotor applies an equal and opposite torque to the body. In the air there is no external torque about the vertical axis to balance it, so the total angular momentum about that axis must stay constant (zero, if it starts at rest):
Irotorωrotor+Ibodyωbody=0
As the rotor gains angular momentum in one sense, the body must gain an equal angular momentum in the opposite sense, and it spins the other way.
(b) The tail rotor, far from the main axis, blows air sideways and receives a horizontal thrust from it. Its line of action is at a large perpendicular distance from the main rotor's axis, so it gives a torque about that axis. This is an external torque from the air, and it is set equal and opposite to the reaction torque from the engine, so the net torque on the body is zero and it does not spin. Changing the tail rotor's thrust lets the pilot turn the helicopter deliberately.