A soap molecule has a hydrophobic end and a hydrophilic end. In other words, it is both hydrophilic and hydrophobic, and because of this, it corrals water, separating it from the air as shown here.