I have read that as per Mahabharata (Anushashana parva) where upamanyu says that - there was no deity like Shiva , there was no refuge like Shiva. There is no one who can give so many boons like him & no one was equal to him in battle. But recently I came across that sabha parva of Mahabharata mentions that Lord Krishna had defeated Lord Shiva when he had taken the side of Banasur. So,these two statements are confusing or how it can be possible? Please clear my doubt.
This is a hard question to answer factually. However thankfully there are some passages from The Puranas and The Mahabharata that can be used to answer this.
First let me answer this based on the passages from the Puranas and The Mahabharata. Then I will add my personal opinion.
In Puranas that glorify Vishnu, the implied answer to this question is simple - which is, that Lord Vishnu is superior. So naturally in a duel, he prevailed.
But in The Shiva Maha Purana, in Rudra Samhita, chapters 54 and 55 deal with this story of Lord Krishna cutting off Banasura's hands, and Lord Shiva intervening to help.
As per the slokha 55 of chapter 54 of Rudra Samhita, Lord Krishna tells Lord Shiva that He is infact directed by Lord Shiva to punish Banasura, because of the curse Lord Shiva pronounced on Banasura. The story goes like Lord Shiva pronounced a curse on Banasura saying his hands would be cut off by Lord Krishna. So Lord Krishna reminds Lord Shiva in this chapter after a eulogy and hymn.
In the next slokha, which is slokha 56, Lord Krishna requests Lord Shiva for permission to carry out the act, and also requests Lord Shiva to leave the battle field and not support Banasura. The slokha says
aagnaam dhEhi praBHO ! mE tvam bAnasya BHUjakrntanE
Then in slokha 59 of the same chapter, Lord Shiva responds by saying he is bound to protect his devotee. He says Lord Krishna cannot do that easily in Lord Shiva's presence. The verse is as follows -
kim karOmi ramAnAtha! bhaktAdhIna sadhA harE !
pashyatO me katham vIra! syatbAnaBHujakrntanam
In the next slokha #60 Lord Shiva offers a solution. Lord Shiva tells Lord Krishna to use Jrumbhastram to make Lord Shiva tired (make yawn), and then go ahead doing whatever he needs to do with Banasura and be happy. The slokha says
atastvam jrumbhamAstrEna maam jrumBHaya madAgnyaya !
tatastvam kuru kAryam svam yaTHeshtam cha sukhi bhava
The slokhas 62 and 63 of the same chapter say that as per the advice and permission from Lord Shiva, Lord Krishna invoked Jrumbhastra to make Lord Shiva tired and sleepy. And during that time, Lord Krishna severed Banasura's arms.
And in the next chapter, which is 55, slokha 28 says it was Lord Shiva in the form of Lord Krishna, fought with Banasura. The slokha says
Evam dvayOschiram kAlam baBHUva sumaHanrana(ha)|
shivarupO hari krishna sa cha shaivOttamO bali||
So if you accept Shiva Purana, this is the reason - Lord Shiva explicitly consented to the act of Lord Krishna, as He pronounced a curse on Banasura. Instead of Himself carrying out a curse on someone who became His devotee later, HE orchestrated this through Lord Krishna.
Now let us look at The Mahabharata for some interesting reference (can be taken as an indirect explanation for your question)
In The Drona Parva, specifically in the Maha NarayanAstra (MOksha) parva, there is a story that narrates how Lord Narayana performed penance and obtained boons from The Lord Shiva. The slokhas 81 to 85 talk about various boons Lord Shiva confers on Lord Narayana. In each slokha, Lord Shiva tells Lord Narayana that HE (Lord Narayana) would be invincible and nothing could cause him any trouble. In each slokha Lord Shiva pronounces the names of various groups, and weapons that will be ineffective against Lord Narayana.
slokha 80: matprasAdAt manushyEshu dEva ghandarvayonishu|
apramEya valAtmA tvam nArayana bhavishyasi||
slokha 81: na cha tvAm prasahishyanti dEvAsuramahOraga(ha)|
na pishAcha na ghandharvA na yakshA na cha rAkshasA(ha)|
slokha 82: na suparnAstaTHa nAgA na cha vishvE viyOnijA(ha)|
na kaschit tvAm cha dEvo(a)pi samarEshu vijEshyati|
slokha 83: na shastrENa na vajrENa na agninA na cha vAyunA|
na chardrENa na sushkENa trasEna sTHAvarEna cha||
slokha 84: kaschit tava rujAm karthA matprasAdAt kaTHAnchana|
avi vai samaram gatvA bhavishyasi mamADHIka (ha)||
As per the above verses, Lord Shiva explicitly grants the permission and boon to Lord Narayana to prevail in all forms of battle, against all forms of weapons (shastrAs, astrAs, vajrAyudha etc), also against all kind of opponents (such as dEvas, asurAs, ghandharvAs, rAkshasAs, yakshAs, pisachAs etc), including against Lord Shiva HIMSELF. Lord Shiva offers the boon including the scenario of a duel between BOTH of them (Lord Shiva and Lord NArAyanA). I have highlighted certain words in bold in those slokhas.
So if you want to go by The Mahabharata, then that is your reason as to why Lord NArAyanA prevailed in the battle. It was because Lord Shiva explicitly offered the boon to Lord Narayana to prevail in the battle, even over Lord Shiva, if for some reason, The two GODS would ever be drawn into battle against each other.
My Personal Opinion: I come from The Vedic school of thought, and I mostly go by the concepts and Truths found in The Upanisads. Though I take the slokhas in Puranas, and the morals, I am on the side of the people who believe Puranas are latter evolutions, and sectarian in nature. This has been my observation for many years, and every thing I have read only reinforced this notion.
The Puranas vary widely in the details,and there are many variations even when it comes to the same story and incident. Srimad Bhagavatam, Sri Vishnu Puranam, Sri Brahma Vaivarta Puranam, and many other Puranas (like Agni Purana, Harivamsam..) narrate the story of Lord Krishna cutting off the hands of Banasura. In fact it is the story that is widely repeated in the Puranas only second to the story of Daksha's sacrifice (which is found in many Puranas, again with varying, and sometimes conflicting details). But they all differ in the details, specifics, and accounts.
As per The Vishnu Maha Purana, Lord Krishna invokes Vishnujvaram to neutralize the Shivajvaram that was invoked by Lord Shiva. But Srimad Bhagavatam does not mention this at all. As per Srimad Bhagavatam Lord Krishna invokes a weapon to put Lord Shiva in sleep. This aligns a little bit with the Shiva Purana version I quoted above, in which Lord Shiva explicitly asks Lord Krishna to use jrumBHAstram. Except that in Srimad Bhagavatam Lord Krishna does not get any advice or permission from Lord Shiva. In Brahma Vaivarta Purana, there are additional battles between kAlAgni Rudra and Lord Krishna's generals and forces, which is not mentioned either in Sri Vishnu Purana or Srimad Bhagavatam (or any other Purana that I have read).
So as you can see, The Puranas are not in congruence with each other, even with respect to the same incident / story / account.
Personally I do not believe, or accept any such fights / battles between GODs. None of these incidents / stories can be explained or reasoned as per the portrayal of the Brahman in the Upanisads.
Nonetheless, I have done by best to answer your question based on the Puranic incidents and passages above. Hope this helps.