Since this circuit is powered directly from AC-mains through a capacitive dropper circuit (C1) there needs to be some form of voltage clamping for the low voltage supply across C2, C3 and C4. Without that IC1 would be destroyed when too little current is drawn as that 24 V could become much more than 24 V.
So D2 and D4 must be zener diodes otherwise they would serve no purpose.
The relay is engaged by closing Q2 via the Signal node from the right. Note how relay coil and Collector-Emitter of Q2 are in series and that combination is across the 24 V supply rail.
Q1 is an oddity, it will only close when Q2 is open so when the relay is not engaged. Then (Q1 closed, relay off) Q shorts D4 meaning that only D2 will clamp the supply. So in this situation, the supply voltage will be somewhat lower as there is now only one zender diode (D2) clamping it.
A possible reason for this configuration is to save some power. When the relay is on then it will draw some current so less current can flow through the zener diodes (D2 and D4).
When the relay is off it does not draw current so perhaps that would cause the supply voltage to rise too much, this is prevented by using only one zener diode (D2, and shorting D4).
For this to work properly I would expect that D2 and D4 have very different zener voltages, for example D2 = 20 V and D4 = 4 V for example.