The CARNOT CYCLE consists of the four cyclic processes namely:
Process (1-2) : Isothermal Expansion ( heat addition Q1 from hot thermal reservoir T1 and WORK OUTPUT is done )
Process (2-3) : Isentropic Expansion ( the system does WORK ie WORK OUTPUT by further expansion )
Process (3-4) : Isothermal compression ( work done by the surounding on the system where heat Q2 is rejected to the surrounding)
Process (4-1) : Isentropic compression ( further compression of the gas and tempreature reaches T2)
From the T-S diagram you get a better explainaition. The Work done on the system is during porcess (3-4) and process (4-1) and the Work done by the cycle is during process(1-2) and process (2-3).
The HEAT SUPPLIED in the cycle ie Q1 is PARTIALLY converted to WORK during process(1-2) and the thermal energy stored still in the gas is used to EXTRACT more WORK ISENTROPICALLY during process (2-3) by expansion (in ISENTROPIC process the system is thermally insulated so greater amount of the thermal energy can be utilised to produce WORK).
THus the HEAT SUPPLIED is PARTIALLY converted to WORK and the rest is rejected as heat Q2.
Thus there is some work done ON the system and some work done BY the system. The useful work is WORK DONE BY the system.
And as explained HEAT SUPPLIED = WORK DONE + HEAT REJECTED
Therefore, WORK DONE = HEAT SUPPLIED - HEAT REJECTED
W = Q1 - Q2
and in your equation 1 there is an alternative positve and negative sign for energy interaction in every process. It is well explained from the P-V diagram itself.