Like amphotericin B and natamycin, nystatin binds to ergosterol, a major component of the fungal cell membrane. When present in sufficient concentrations, it forms pores in the membrane that lead to K+ leakage and death of the fungus. Ergosterol is fairly unique to fungi, so the drug does not have such catastrophic effects on animals.
Sterols work in a similar manner such as those found in yucca root and jiaogulan.
Cancer cells are killed by sterols through the binding of cholesterol in cell membranes then "ripping" it out lysing the cells.