As air moves over the olfactory membrane, odor molecules settle on the scent receptors and get recognized.
The more air there is flowing over the membrane, the more scents the dogs can detect.
So when a dog sticks its head out the window, it's like pigging out at a hi-definition all-you-can-smell scent buffet.