Foam is a substance with so many tiny air bubbles that it becomes frothy or thick. Your liquid shampoo becomes a foam as you lather it into your wet hair.
There's a layer of foam on top of your root beer float, and shaving cream usually comes out of its can in the form of foam. When something froths up this way, you can say that it foams, like turbulent ocean water or a bubble bath that grows as you add water to the tub. The Old English root word is fam, which means "foam," but also "saliva froth" and "sea."