Foam does nothing for cleaning per se. But then why do people still use it?
It allows for two things, longer dwell times and some resistance against product drying out, which makes it beneficial in hot weather.
Now what does foaming do? Foaming means that you use air to create a foam out of a water and cleaner mixture. Not all types of cleaners contain the correct chemicals to actually foam and some even contain inhibitors to not foam at all (some fabric cleaners for example, to not foam up in the sewage tank of the extractor).
The foam is less dense and sticks to the paint, which is why it is usually better to foam a dry car (also because the standing water would further dilute the cleaner). The chemicals in the foam now have more time to work on the dirt in hotter climates so the chemical can stay on the paint for longer. Exceptions for this are if the car is either full of mud or hot and you want it to cool down first.
What kind of consistency of foam do I want?
A wet foam that actually pulls down in a few minutes is mostly what cleans best as with more air the amount of chemicals with surface contact decreases. A too air-y foam (As in shaving cream foam) might look good on the social media of your choice but actually cleans worse then a wet foam.
Does a product clean better when it foams up?
Foaming action by itself when agitated also means nothing in terms of cleaning power, it only means that a certain kind of foaming cleaning chemical was used.
There is a good reason for Foam on other parts of the cleaning process. For leather and especially open porous leather, foam is much appreciated as it is dryer vs. using a wet cleaner so the moisture can not penetrate too deep into the material. The dryness of foam is much appreciated there where on other surfaces a wetter approach will give the dirt more place to be.