They are looking for heat signatures from a animal. The tongue tells them what is around them.
If the species of snake is different than it will flick its tongue differently because its surroundings will change
Snakes breath through nostrils like you and me, but if you mean how do they smell, then the snake's sense of smell is in it's tongue, which is why snakes flick their tongues a lot.
This is called a flicking of the tongue. A snake smells with its tongue, so it will flick its tongue a lot. it uses its tongue for sensing its prey and when it gets close enough it leaps and bits.
They flick out their forked tongue to gather molecules form the air and then draw the tongue back into the mouth over their organs of taste/smell in the roof of their mouths.
When a snake flicks its tongue, it is essentially "tasting" the air. Various chemicals are picked up by the appendage that inform the snake of things like atmospheric conditions and the general direction of prey.
With there tongue! They flick their tongue in and out of their mouth to sence the air when the tongue is out it picks up scents and when it is flicked back into the mouth it rubs against the jacobsons organ which converts the sences and allows the snake to understand its surroundings
A snake doesn't really 'smell' to say the least. They have a special organ in the nasal cavity of their skulls called the Jacobson's Organ. When they flick their tongue out, they use that organ to sense any nearby prey or threat. So in a sense, they 'smell' while they taste the air.
Assuming you mean 'why do snakes flick out their tongue'... It's basically a sensory organ. The snake is 'tasting' the air. Each side of the the fork is independent from the other. When the snake flicks out its tongue, it collects microscopic scent particles from the air. Withdrawing the tongue into its mouth, there is a sensitive group of nerves in a 'pocket' where the snake inserts the tips. This translates the scent into messages for the snakes brain. The minuscule difference in strength of the scent on either side of the tongue enables the snake to follow the stronger scent to locate its prey.
Ralphie
A snake
So it can flick the tongue out long to catch prey