Why is Face ID on used iPhone X and XS often not working?

The simplest explanation is that they've had their screens broken and the replacements weren't done by Apple themselves.

The FaceID [and TouchID] secure enclave chips cannot be replaced by anyone other than Apple. If they are in any way disturbed by a third party, they will cease to function.
This is a security measure.