The science — how it actually works
What it actually is: a surfactant solution. Surfactant molecules have a water-loving head and an oil-loving tail — they lower water's surface tension so it can wet the panel properly instead of running straight off, then grab hold of the oily road film.
Why foam at all? Foam isn't the cleaning agent — it's the delivery system. Its only job is dwell time: clinging to a vertical panel long enough for the surfactants to emulsify road film and encapsulate loose grit so it rinses away instead of being dragged across your clear coat by a wash mitt.
That's the whole point. The scratches in your paint mostly aren't from the road. They're from washing. Pre-wash removes the ammunition before you ever touch the car.