A 2-bit comparator compares two binary numbers, A and B, and determines if they are equal using an XNOR logic gate. The XNOR logic gate produces a high (1) output only when the two inputs A and B are the same. Otherwise, the XNOR output is low (0), indicating A does not equal B.