LM311 is a comparator, not an op-amp. The designer has configured it to have some hysteresis, probably to avoid any false triggering of the circuit.
In that configuration, the output transistor of the LM311 will switch ON when the input voltage from the connector goes below a certain threshold (667 mV). The designer must have concluded that if the input voltage goes below that threshold then it is an actual power off, and not just a temporary droop.
Another thing that happens when the input voltage goes down, is that diode D2 will isolate the capacitor bank of the 12V rail from the input voltage line, but they will still be charged at 12V. More on this later.
Going back to the LM311, we find out that switching off its output will switch off Q2, which in turn will turn on Q1. When Q1 turns on it will switch a 6 Ohm load to ground, which will generate across it quite a high current from the 12V rail.
That current will quickly discharge all the capacitor connected to the 12V rail, provided the fuse doesn't blow in first place. If an adequate fuse is selected, the initial 2 A peak current will not last enough to blow it. This way Q1 and the resistor will be protected from a faulty operating condition (continuous 2A conduction) but still be able to do its work under normal conditions.
So, what's this circuit intended for? Probably for discharging quickly the 12V rail capacitor, as Andy aka says. Why such a thing is needed is a question that can only be answered by the designer of by careful analysis of the broader design.
Note that the designer could have opted for connecting a bleeding resistor between the 12V rail and ground, but that would have greatly increased the current consumption if the discharge time required is short. What the designer does here is connecting a strong bleeding resistor when it's required only (at the expense of a greatly increased complexity).