I could think of plenty of examples where a paying passenger who is also an official with statutory powers can demand to see ID if they have reason to believe an offence is being or has been committed by the railway staff member involved. Police, Customs & Excise/VAT inspectors, Immigration officers, all operate both in uniform and in plain clothes, and that's just the start of the list. Obviously no railway staff member who posts here could ever possibly have committed any kind of offence, but that won't prevent them from being suspected.
Refusal to provide the ID is likely to intensify the suspicion and produce unpleasant if short-term consequences. Of course in some cases the refusal is itself an offence. Sound familiar?
Incidentally, while Flamingo is correct about uniformed PCs, officers not in uniform can't avoid giving names and/or displaying warrant cards if challenged when claiming to be a police officer, and of course officers above the rank of sergeant don't have numbers in the first place.