a) Gandalf never casts fireball. Close reading of the text is that Gandalf can set things on fire (by commanding them to burn) but cannot summon fire out of the air. While the 'fireball' has its origin in Gandalf, like many of the things inspired by LotR in D&D it's not a good implementation of Gandalf's actual abilities.
b) Gandalf has an elven ring of power equivalent to a Ring of Elemental Command (Fire) and a Staff of Power (the origin of the D&D 'retributive strike' ability appears to be Tolkien - 'You shall not Pass.').
c) Gandalf's encounter with the Ring Wraiths on Weathertop is not shown in the text, and we cannot therefore state with any precision what spells he used. It's been a while since I read the text of 'The Hobbit' but since I have read it 36 times I think I can go from memory that Gandalf tells Beorn that he cast "a lightning bolt". I don't remember either multiple lightning bolts in chapter were it happens or Gandalf's recounting of it. The only other 3rd level spell he uses after that in the text is "pyrotechnics" which he casts in the goblin Great Hall, and after that he noticeably stops casting spells until after Bilbo's escape the next day and fights with his sword.
d) Personally, I believe Gandalf is probably a 6th level wizard and you are correct that 6th level is more accurate of an assessment than 5th level, but also I believe that Gandalf isn't just a 6th level wizard. However, it's not outside of the text that he could be a 5th level wizard with a magical staff and a powerful ring. Personally, I believe that he is a 6th level wizard with a magic staff and a powerful ring, but also that in 1e AD&D terms his race is Agathion which explains why despite being similar level to the other heroes he's a much more puissant individual. In 3e terms, he's a +LA race.