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.