The events of Chapter 2, "The Shadow of the Past," are:
* Thorin Oakenshield and his company of dwarves arrive at Bag End. They are seeking the help of Bilbo Baggins, who is a distant relative of Thorin, to join their quest to reclaim their homeland from Smaug the dragon.
* Bilbo is initially reluctant to leave his comfortable home. However, he is persuaded by Gandalf, who believes Bilbo's skills and courage are needed for the adventure.
* The dwarves and Bilbo set off towards the Misty Mountains. They encounter trolls who are planning to eat them for dinner.
Gandalf, using his magical abilities, tricks the trolls into arguing until the sun rises. This forces the trolls to turn to stone, effectively saving the dwarves and Bilbo from their clutches. This incident, however, happens in Chapter 3, "Three Trolls."
So, while Gandalf does play a crucial role in the story, he doesn't actually rescue Bilbo and the dwarves in Chapter 2. He does, however, help convince Bilbo to join the adventure and plays a key role in helping them escape the trolls in the following chapter.