Why do certain groups withdraw/ donate electron to double bond or conjugated system in resonance effect?
Generally, it is observed that if there are lone pair(s) present on the atom of function group directly attached to to the conjugated system, then $+R$ effect is observed.

If the same atom has double bonds or dative bonds with another atom, then $-R$ effect is observed.

Example: –$\ce{OH}$ shows +R due to 2 lone pairs on Oxygen.
— $\ce{NO2}$ shows -R due to one double bonds between Nitrogen and Oxygen, and one dative bond from Nitrogen to another Oxygen.