Styrofoam works fairly well for neutrons, not so much for gammas.
Yes, well, and for charged particles, as it avoids bremsstralung X-ray generation.
However, the reason foam is used is to provide other functions as well, as it would work just as well if it were crushed to a solid.
So on the ISS, using foam (especially if its doped with high-Z materials) also provides thermal insulation and micro-meteoroid protection.
On subs, if foam is used, its very dense foam, and it provides secondary benefit of thermal insulation (ie on e primary water loop and around turbo-machinery).
With nuclear, the form of the material matters relatively little--it's effectively purely the mass of stuff per unit area, secondly what stuff, and thirdly, what order the stuff is.
If its fast neutrons, you want as much hydrogen atoms you can put in the way.
For slower neutrons, you want absorbers like cadmium, boron, lithium (the later work best as there is minimal secondary radiation)
For x-rays and gamma rays, you want as many electrons as possible (high atomic number materials) in the way.
Fr charged particles (protons, etc) you just want stuff...but preferably lower Z materials if you want to avoid secondary radiation
That's why most "general" shields are heavy metals (eg lead) to block photons (x and gamma rays), boron loaded plastic (neutrons)