Perhaps a lot of the differences between the Gandalf of
The Hobbit and that of
The Lord of the Rings can be attributed to writing style. The former is a children’s book; the latter is written for a mature audience. The early Gandalf will be shown in fewer dimensions and more simply for the sake of the audience. He is wise and knowledgeable, but mostly gruff, a father figure of sorts. This same gruffness comes through in
The Lord of the Rings, especially in Gandalf’s interactions with Pippin, but is blended with a dozen other attributes that Tolkien has time to develop through the course of the (much longer) book. It is also worth noting that the Gandalf of
The Hobbit is given less focus and time to develop; a great portion of the book is left for Bilbo’s growth. It is likely that Tolkien’s ideas about Gandalf changed to a degree by the time he finished
The Lord of the Rings; the gap between the publishing dates of the two works gave him lots of time to “discover” his characters.