(A) Soaps are $Na^+$ or $K^+$ salts of long-chain carboxylic acids.
Detergents are ammonium or sulphonate salts of long-chain hydrocarbons.
Cleansing action of soap: $A$ soap molecule has two parts: a hydrophilic (water-loving) ionic head and a hydrophobic (water-repelling) hydrocarbon tail. The tail attaches to oily dirt,while the head remains in water. This forms a structure called a $micelle$. When rinsed,the $micelle$ is washed away,carrying the dirt with it.
Soaps do not form lather in hard water because they react with $Ca^{2+}$ and $Mg^{2+}$ ions present in hard water to form an insoluble precipitate known as $scum$.
Problems due to the use of detergents:
$1$. Most detergents are non-biodegradable,leading to water and soil pollution.
$2$. They can cause skin irritation or allergic reactions in some individuals.