Was it splashing into the brew pot or did you have a tube run all the way to the bottom of the brew pot?
If it was splashing the foam is aeration of the wort. If you believe that hot side aeration is bad for homebrew you should run a high temp house to the bottom of the brew pot so that there is no splashing.
If you are running a hose and minimizing splashing my guess would be that you were stirring the mash vigorously got a lot of air dissolved into it and it is coming out of solution when draining.
Did you use any cleaners on the mash tun that might have foamed (soap in particular)? I use exactly 3 things on my mash tun. Water, star San, and PBW/OBW no scrubbing, no household cleaners.