It amplifies sequences that contain the two primer sequences on each end of the target. So if you had synthesized sequence XYZ with some mistakes like YZX, then you could target X and Z and purify.

You're correct that PCR has a limited max length, but it is longer and cheaper than vanilla DNA synthesis.

Kary B. Mullis Nobel Prize lecture Nobel Lecture, December 8, 1993

The Polymerase Chain Reaction

https://www.nobelprize.org/prizes/chemistry/1993/mullis/lect...