This mysterious foam is actually just a buildup of protein and other natural sea contents washed ashore.
Commonly, decaying algal blooms create this thick sea foam. Large algal blooms decay in the water which will often find its way to the coast. However, the foam forms as the organic matter gets mixed up and moved by the current.
Don’t worry, the foam isn’t a danger to people or the environment. It’s actually a symbol of a productive marine ecosystem.