Why do certain groups withdraw/ donate electron to double bond or conjugated system in resonance effect? Why for the Resonance effect certain group of substituents/functional group donate electron from the double bond or to a conjugated system while some withdraw electron from the double bond or to a conjugated system? What causes the groups/substituent to withdraw or donate electron causing +R and -R 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.