There are several common sorts of soapy things. They attract oils by electric charge, allowing the oil to be emulsified with the water. For some reason, these cleaners are themselves made from fats. Soap is made from animal or vegetable oil, and detergent is made from mineral oil. Detergents can be made more powerful.
Shampoo is detergent, just like dishwashing detergent, bathroom cleaner, and engine block cleaner.
Soap was better suited to washing hair, because it didn't remove so much of the oils that are naturally in hair. But the water supply slowly changed. It's now generally more alkaline, which people call hard water. When this started happening, soap didn't work so well. So soap got less and less effective for all its cleaning uses.