If the claims are non-novel or obvious, then the examiners, who are familiar with the state of the art in the field, will reject them. Maybe the applicant will amend the claims to claim something narrower, or maybe not.
If the examiner and patent office screw up and allow a claim that shouldn’t have been allowed, then the claim can be challenged later and revoked. Yes, that costs money and is inefficient sometimes.