Here Vishnu disguised in the form of Ashura made his wife lose chastity, he was not punished.But When Brahma entered the abode of Parvathy, his fifth head was severed and shiva attained Brahma Kabala and Brahma did not have temples in the earth and also has only four heads because of his act.Even Shiva as Bhishadana made rishi's wife abandon chastity due to rishis ignoring god and believe only in karma. How these stories justified when there is partiality to Brahma?
I'm not sure what story you are referring about Brahma. Rudra cut Brahma's head when Brahma attempted incest with his daughter Saraswati as described in Shatapatha Brahmana of the Yajur Veda.
Pragâpati [Brahma] conceived a passion for his own daughter... 'May I pair with her!' thus (thinking) he united with her. This, assuredly, was a sin in the eyes of the gods. 'He who acts thus towards his own daughter, our sister, [commits a sin],' they thought. The gods then said to this god who rules over the beasts (Rudra), 'This one, surely, commits a sin who acts thus towards his own daughter, our sister. Pierce him!' Rudra [i.e. Shiva], taking aim, pierced him.
Even Jnanasamhita of Shiva Purana narrates a similar story.
Brahma desired Sarasvati and went to her, asking her to stay with him. She, being his daughter, was furious at this and said, 'Your mouth speaks inauspiciously and so you will always speak in a contrary way.' From that day, Brahma's fifth head always spoke evilly and coarsely. Therefore one day when Siva was wandering about with Parvati and came to see Brahma, Brahma's four heads praised Siva but the fifth made an evil sound. Siva, displeased with the fifth head, cut it off.
However, Matysa Purana doesn't consider this as incest. But we should consider Vedas or Sruti as infallible truths over other scriptures. (I will update this answer for Brahma once OP provides details about Brahma story).
However, both Vishnu and Shiva were cursed in those cases though they had fair reasons for their actions.
Story of Vishnu and Vrinda :
Vishnu was cursed by Tulasi to get seperated from His wife and demons would kidnap His wife (alluding to Rama Avatar). But Parvathi asked Her brother Vishnu to defile Vrnda only when Jalandhara went to Parvati in disguise as Lord Shiva.
यावद्ददर्श चार्वङ्गीं पार्वतीं दनुजेश्वरः। तावत्स वीर्यं मुमुचे जडाङ्गश्चाभवत्तदा॥४१॥
On looking at the beautiful Parvati, by the lord of Daityas, his semen fell on the ground and all his limbs became benumbed
अथ ज्ञात्वा तदा गौरी दानव भयविह्वला। जगामान्तहिंता वेगात्सा तदोत्तरमानसम्॥४२॥
Thereafter, when Gauri came to realise, the truth that he was a Daitya and not Siva, she disappeared from the site and went to northern shore of the lake Manasa.
पार्वत्यपि महाविष्णु सस्मार मनसा तदा। तावद्ददर्श तं देवं सोपविष्टं समीपगम्॥ ४४॥
Then Parvati remembered lord Visnu mentally and she found atonce that the lord was seated before her.
Also, Jalandhara just wanted to take revenge on Devas since Devas acquired gems and pearls during churning of ocean. But Indra had his reason for stealing gems since Ocean God hid mountains in him when Indra was cutting their wings. This is because mountains were disturbing yagnas and killing people when landing.
This is what vrinda cursed Lord Vishnu for defiling her chastity as a part of Shiva's mission.
इत्युक्त्वा क्रोधमापन्ना दर्शयन्ती स्वतेजसम्। शशाप केशवं व्यास! पातिव्रत्यरता च सा।।४२।
Sanatkumara said, "Thus speaking, and getting enraged, she displayed her excessive brilliance as a chaste lady, she pronounced a curse on Kesava.
रे महाधम! दैत्यारे! परधर्मविदूषक!। गृहीष्व शठ! मद्दत्तं शायं सर्वविषोल्वणम्।।४३।।
“O Immensely degraded enemy of the demons, you shatter the dharma of others. O Wicked one, you listen to my curse, which is greater than all poisons, and you should receive it.
यौ त्वया मायया ख्याती स्वकीयौ दर्शितौ मम। तावैव राक्षसौ भूत्वा भार्या तव हरिष्यतः॥ ४४॥
By displaying the two Raksasas to me with your illusion, they would be turned as the demons in reality and shal kidnap your wife.
त्वं चापि भार्यादुःखातों वने कपिसहायवान्। भ्रम सर्वेश्वरेणायं यस्ते शिष्यत्वमागतः॥ ४५ ।।
You, yourself, suffering from the separation of your wife, with the lord of serpents who is acting as your disciple, will wander in the forest with him.'
Story of Shiva and Darukavana Sages:
Shiva wanted to test devotion of sages who were doing Yagna for Shiva Himself. But He wanted to test their devotion in different way. He took form naked ascetic who was in black complexion.
Wives of sages were attracted to Him and sages cursed Him. This is how Chapter 29 of Linga Purana describes this incident.
प्रवृत्तिलक्षणं ज्ञानं ज्ञातुं दारुवनौकसाम्। परीक्षार्थ जगन्नाथ श्रद्धया क्रीडया च सः ॥७॥ निवृत्तिलक्षणज्ञानप्रतिष्ठार्थं च शङ्करः। देवदारुवनस्थानां प्रवृत्तिज्ञानचेतसाम्॥८॥ विकृतं रूपमास्थाय दिग्वासा विषमेक्षणः । मुग्धो द्विहस्तः कृष्णाङ्गो दिव्यं दारुवनं ययौ ॥९॥
Lord Rudra, the master of the universe, then thought of testing the intentions of the ascetics, who had performed the Vaitia. Then, he thought of diverting the minds of the sages from the performing of the yajia. In this way, in order to test the extent of their devotion towards himself, he thought of diverting their minds in a different way. Therefore, in order to test their devotion towards himself, he playfully appeared in a deformed manner, but still he was quitecharming to look at. He had there eyes and two arms. He was of black complexion and unrobed.
The sages spoke harsh words to Rudra and cursed Him. Later Shiva Himself explained the Darukavana sages subtle and esoteric significance behind His Digambara appearance in Chapter 34 of Linga Purana.
नग्ना एव हि जायंते देवता मुनयस्तथा। ये चान्ये मानवा लोके सवें जायंत्यवासस: ॥१३॥ इंद्रियैरजितैर्नग्नो दुकूलेनापि संवृतः । तैरेव संवृतैर्गुप्सो न वस्त्रं कारणं स्मृतम्॥१४॥
A person who is clad in costumes, but if the sense organs remain uncontrolled, then the person is as good as naked. But in case, the sense organs of a person are well controlled then, he inspite of his being naked, would be like a well clad person. Under such circumstances, the costumes are of no importance.
क्षमा धृतिरहिंसा च वैराग्यं चैव सर्वशः। तुल्यौ मानावमानौ च तदावरणमुत्तमम्॥१५॥
To practice forgiveness, patience, nonviolence and Vairāgya (renunciation) and to treat honour and dishonour equally, serve as the best costumes for the body.
This chapter also explains significance of Ashes.
So, even though Vishnu and Shiva did Dharmic acts, they were cursed.