This question is based оп Illustration (b) of Section 76 of IPC, 1860. Section 76 provides that nothing is an offence which is done by a person who is, or who by reason of a mistake of fact and not by reason of a mistake of law in good faith believes himself to be, bound by law to do it.
Illustration (b): A, an officer of a Court of Justice, being ordered by that Court to arrest Y, and after due enquiry, believing Z to be Y, arrests Z. A has committed no offence.