Ever see a NASCAR car slow down to do a turn? Same thing.
It's all about timing.
Aveodude said it pretty well, but it mostly happens when it shifts up or down, as well as go from low to very high RPMs and vice versa.
When it shifts the cylinders are making more or less power than it's using so excess fuel gets out and ignites from the heat.