There's two kinds of gravity assist.
Slingshot uses the motion of the planet around the sun, and pulls the probe along with it in the same direction that the planet is orbiting the sun.
The probe comes in perpendicular to the solar orbit, and leaves parallel to the solar orbit, and faster (relative to the sun). Relative to the planet there is no change in speed.
Kind of like bouncing a ball against a moving car. Relative to the car nothing happened, but relative to the ground the ball is faster.
Gravity burn is more complicated. (Oberth effect)
Imagine a stationary rocket (bolted to the ground). All the energy of the fuel is in the exhaust, and none in the rocket.
Now imagine the reverse - a really fast rocket, now way more of the energy is in the rocket (and less in the exhaust).
So what do you do? You fall toward a planet, and at the point where you are moving fastest, you fire your rocket. Now not only does your fuel have the energy inherent in it, it also has all the energy from falling toward the planet.
And this is the big idea here: You leave that fuel behind as exhaust! So when you climb back out of the planet you don't carry the fuel with you.
Normally falling toward a planet, and leaving the planet exactly cancel out. But you used the oberth effect to leave the fuel behind at the point where the fuel has the most kinetic energy.