Foam is a more effective fire-fighting agent than plain water. It smothers and starves, taking away one of the elements of the fire-triangle.
All US Navy surface ships use AFFF (Aqueous Film Forming Foam) as their main agent. Subs don't have room for all that fancy equipment so we make do with AFFF fire extinguishers and fight fires with seawater.