SO3Na

Why does soap become foam-like when it reacts with water (moisture) or when we touch it with wet hands.. What compound actually causes this physical change? And why does this physical change occur?