How Lord Shiva was attracted to Mohini Murti avatar of Lord Vishnu?
Lord Siva cannot be victimized by maya. Therefore it is to be understood that Lord Siva was being thus harassed by Lord Visnu’s internal potency. Lord Visnu can perform many wonderful activities through His various potencies. parasya saktir vividhaiva sruyate svabhaviki jnana-bala-kriya ca (Svetasvatara Upanisad 6.8). The Supreme Lord has various potencies, by which He can act very efficiently. To do anything expertly, He doesn’t even need to contemplate. Since Lord Siva was being harassed by the woman, it is to be understood that this was being done not by a woman but by Lord Visnu Himself.
Once one is agitated by lusty desires upon seeing a woman, those desires increase more and more, but when semen is discharged in the act of sex, the lusty desires diminish. The same principle acted upon Lord Siva. He was allured by the beautiful woman Mohini-murti, but when his semen had been fully discharged, he came to his senses and realized how he had been victimized as soon as he saw the woman in the forest. Thus Lord Siva could understand his position and that of the Supreme Personality of Godhead, who has unlimited potencies. Having reached this understanding, he was not at all surprised by the wonderful way Lord Visnu had acted upon him.
If one is trained to protect his semen by observing celibacy, naturally he is not attracted by the beauty of a woman. If one can remain a brahmacari, he saves himself so much trouble in material existence. Material existence means enjoying the pleasure of sexual intercourse (yan maithunadigrhamedhi- sukham). If one is educated about sex life and is trained to protect his semen, he is saved from the danger of material existence.
Source: A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, Eighth Canto, Chapter 12 – Text 31, 35 & 36