Please explain how this XNOR gate works
If one of the switches is high, and the other low, there's a path for current to flow around the circuit through the transistor base. E.g. in the first image, S1 is high and S2 low, so current flows from the positive side of the voltage source through S1, D1, the transistor base, D2 back to the negative side of the voltage source.

If the switches are flipped, it would flow through D4 and D3 instead. Similarly, the collector current also reaches ground through either D2 or D3.
If both switches are low, or both are high, the ends of the loop passing through the transistor base are connected to the same point, either ground or the positive voltage. Either way, there is no voltage difference around the loop, and no current.
Similar circuit simplified in the Falstad simulator.