Why is sound reflected and not transmitted through a wall?

Whenever a wave reaches a boundary between two mediums some of the energy is reflected and some is transmitted.
The important parameter is not just the speed of the wave on either side of the boundary but what is called the acoustic impedance (= density $\times$ speed). If there is a large difference between the acoustic impedances then you will get most of the wave reflected.
So if you have an air (speed of sound 330 m/s, density 1.2 kg/m$^3$) brick wall (4200 m/s, 1850 kg/m$^3$) boundary a lot of the sound will be reflected.

So when you walk down a tunnel the sound that you emit gets reflected off the walls and even off the open end of the tunnel and comes back to you as an echo.


Sound follows like everything else in nature. Minimize energy. So while sound can travel faster in a denser medium, the fact that sound is produced by mechanical waves mean that more energy is required to transmit the sound 100% through the wall with the same intensity.

And just like any other wave, when a sound wave hits a solid object like a wall, it will undergo reflection, dissipation and transmission. This transmission usually reduces the intensity of the travelling sound wave which is why when you are in an adjacent room, you can hear a fain part of the conversation from the next room. But at the same time, if the wall is made from a very dense material, then the sound waves don't have enough energy in creating mechanical waves in the material of the wall and thus you usually end up with only reflection (echo) and some dissipation.


When sound gets reflected by a wall, some portion of the sound is reflected back to air, some of it is converted into heat energy and lost in the atmosphere and some of it indeed gets transmitted through the wall. This is evident due to the fact that we are able to hear sounds coming from completely closed structures such as rooms. You might have noticed that loud sounds can make things vibrate.