A prequalification will not affect your credit as long as the lender uses an estimated credit score or a soft inquiry.
During the prequalification process, lenders are not required to officially verify credit or financial information. Instead, they often rely on self-reported information. Some lenders will perform a soft credit check, but this won’t show up on your credit report.
However, this means that the prequalification should only be considered a rough estimate. It’s not a thorough check of your credit history. The affordability estimate may change once you apply for a mortgage or preapproval.