General Elessar wrote:
If Gandalf wanted to fight the Balrog, why did he first try to go over the mountains?
Because he still wasn't sure of his eventual fate.
I don't mean he actively sought the Balrog, otherwise he would have gone straight to Moria alone after being rescued from Orthanc, but once the company entered Moria I think he realised where it was all leading and accepted that this was the only way to become the White Wizard that Saruman should have been. Bare in mind Saruman had already succumbed at this point so the Valar had no powerful Istari in charge in Endor, they needed Gandalf to be reborn. I've changed my mind that he knew the Balrog was there before he saw it, but he did want and need to fight it.
Remember Aragorn says, '...it is not for the Ring, nor for any of us others that i am thinking now, but of you, Gandalf. And I say to you: if you pass the doors of Moria, beware!' Aragorn felt that Gandalf had a destiny that had not yet been fulfilled.
Also when the Balrog appears Gandalf says to himself,
'A Balrog,' muttered Gandalf. 'Now I understand.' He faltered and leaned heavily on his staff. 'What an evil fortune! And I am already weary.' At that moment he recognised what fate had in store for him and why he had come into Moria.
It a bit like the story of Jesus and the resurrection, he knew he had to die to come back stronger, he didn't seek death but he accepted it had to happen. Same with Gandalf I think, Gandalf realised fighting the Balrog would destroy him but make him stronger to fight Saruman and Sauron.
Having said all that I disagree with TheOneRider that Gandalf was simply killing the Balrog to make the war of the ring easier. I don't think the Balrog would have been used by Sauron against Gondor.