Character Analysis
The Wiz
Don't go consulting Harry Potter if you want to understand Gandalf's wizarding ways. He doesn't drink Butter Beer, there are no phoenix feathers in his magic wand, and he's never had to suffer through Herbology lessons.
Neither is he a wizard of the Merlin-from-The Sword In The Stone school. He's not some crusty old dude who has a few magical powers and experiences time backwards.
Instead, he's a special brand of Middle-earth wizard. Wizards were Maiar (or lesser Gods) who became incarnate and traveled to Middle-earth to guide the beings that dwelled there.
Yup: Gandalf is literally a god.
And we know that he's been around a while and knows a thing or two about a thing or two. He may not be as powerful as Saruman, but he's not too far off. Gandalf is the bearer of Narya, an elven ring of power known as the ring of fire. We see him scouring the earth, travelling to Mordor and dusty archives to learn about the ancient history of the One Ring. He's also in tight with the elven king Elrond and the Great Eagle king Thorondor. And when Saruman reveals the Palantír to him, Gandalf knows of the danger it may possess.
But despite his wisdom, Gandalf is not powerful enough to defeat the demon Balrog. He knows that it's hiding in Moria—which is why he wants to avoid the mines in the first place. At first it appears that he will be able to defeat the Balrog as he invokes his divine heritage and his possession of Narya, saying,
GANDALF: I am the Servant of the Secret Fire, Wielder of the Flame of Anor. The dark fire will not avail you, Flame of Udûn!
The Balrog are Maiar like Gandalf, who were corrupted during the ancient days. Gandalf's battle isn't one between man and beast, but a battle of divinity in which both of them are pulled down to the shadows of Middle-earth.
The Old Man
Gandalf may be an Istari, but in some ways he's also just an old dude. Remember his visit to Hobbiton at the beginning of the film? Gandalf sets off a few fireworks for the children as his cart passes and gets a good chuckle out of it. In Bag End he knocks Bilbo's chandelier a few times before bumping his head on a hobbit-level rafter. As he smokes his pipe and blows fancy smoke-rings, we get the sense that he really is just an old man trying to enjoy life a little bit when he's not out searching the world for signs of darkness.
This persona is integral to his role as a mentor—he not only guides the kings of the world, but also small people (both in stature and importance). Gandalf takes a liking to the hobbits, perhaps because they're so untouched by worldly greed and power-hunger:
GANDALF: My dear Frodo, Hobbits really are amazing creatures. You can learn all that there is to know about their ways in a month, and yet, after a hundred years, they can still surprise you.
There's no doubting the kindness and genuine affection in Gandalf's eyes as he interacts with the hobbits in Hobbiton and Rivendell. Sure, he's often deep in thought about the darkness of Middle-earth, but he's also always trying to protect others from it.