There seems to be some confusion about what exactly sound proofing is, how it can be achieved, and what materials have which superpowers.
First - foam cannot be a wall all on its own; it can fill the same amount of space as a wall, but that does not make it a wall.
Second - What do I mean by foam? I mean those zig-zagging squares or the little pyramid matrices on squares. Like this:
Other materials that are foam-like, but actually block sound to a degree, is rigid fiberglass, as seen in these things:
Rigid fiberglassis designed to deaden sound, whereas foam simply shapes the sound by distributing the sound waves that reflect off it in a uniform way. This makes the sound more pleasant, which is important. You don't want a completely dead room; in fact, I like I rather large room compared to a vocal booth to perform VO in, so I try to deaden as much as I can with rigid fiberglass, then perform near a strategically placed foam board. Which is on a wall. Made of wall.
Soundproofing can go much deeper than the wall's surface. I'll soon be building a second interior wall in my studio soon, in order to further block low end noise from coming in and out.
Depending on your setup, what kind of mic you're using, etc., your sound treatment needs will vary greatly. Closets are great work in, since they're small and need very little material to be deadened/sweetened/whatever is needed. Bigger rooms are more comfortable and can sound a little more natural and open, because...you know, they are. Just know that the space you deal with, the more kinds of problems arise. Parallel reflections (break up symmetry in walls), floor to ceiling reflections (get you a carpet, higher ceilings may need panels, etc), bass buildup in the corners (bass trap the corners...I recommend 4" of good ole 703 Owens Corning rigid fiberglass), and more issues abound. The space around is as important to your sound as your voice and your setup. Hopefully knowing what foam is and what it does and doesn't do will help you treat your space appropriately. There's also, like, math and stuff you can do if you're not comfortable using your ears as your guide. I'll pick at this topic more in the future, as I'm learning as I'm going along as well, and it's a well of really cool information. Til next time!