Egg Cartons and Sound Absorbtion
Egg cartons attached to the wall do not absorb much sound---after all, they are simply recycled cardboard and soak up about as much sound as putting a cardboard box on the wall. Foam materials such as carpets, mattresses and specific sound absorption equipment mute noise much better than egg cartons do, but the point of the egg carton on the wall is not sound absorption---it is echo reduction.
Echoes are undesirable in many audio contexts, from music studio production activities to home theater setups, and can lead to many problems, from unclear sound quality to feedback problems with recording equipment. Egg cartons are used on ceilings and walls to try to scatter the reflecting sound waves, which helps eliminate echoes, as well as for their (small) contribution to sound wave absorption.
Science of an Echo
The reason this echo reduction works is because of the shape of the carton. When a sound wave approaches a hard surface like a wall or ceiling that doesn't have any sort of scattering agent the sound wave reflects off the wall in the same way that a light shined on a mirror will reflect, and returns back to the source of the wave pretty much intact, although delayed. Egg cartons' many textural undulations help break up sound waves, reflecting them in all directions, thus diffusing the echo.