It would be very heavy to carry the water required for making much foam.
If you're landing on a runway, someone's provided vehicles ideal for the purpose, that should be ready and waiting. The firefighters can still put foam where it's needed, and they're only seconds away if they know an aircraft with problems is arriving.
The issue would be to make sure any spilled fuel doesn't ignite after you'd stopped, putting a blanket of foam around and under the stopped aircraft, not as you are still moving: if you sprayed foam while moving, it would just make a messy wake for you.