You probably have too many chemicals in your pool.
Pool foam is almost always from too many chemicals or not enough filtration.
Usually it’s one of three things: low calcium hardness (soft water foams like a bubble bath), leftover algaecide or clarifier, or someone jumped in with too much detergent on their swimsuit. Phosphates from leaves or runoff can also make foam, but that’s less common.
Fix it by testing your water first. If calcium is low, add calcium increaser. If phosphates are high, treat with a phosphate remover. Otherwise, just shock the pool and run the filter longer. A defoamer works instantly but is a band-aid – figure out the root cause.
If it keeps coming back, stop pouring random chemicals in. Less is more.