When a snake flicks its tongue, it’s not threatening you. It’s smelling you. Scent particles drift in the air, stick to the moist surface of the tongue, and get carried back inside.
There, the snake pushes its tongue against an organ in the roof of its mouth called the Jacobson’s organ, which is much better at picking up tiny scent chemicals than a nose. The forked tip is the clever bit: the two prongs sample slightly different bits of air, so the snake gets the smell in stereo - like two ears for a sound - and can tell which side it’s stronger on. That’s how snakes follow trails so well.
Some snakes have a second superpower on top of that. Pit vipers and pythons have small heat-sensitive pits on their faces that let them “see” warm bodies in the dark, almost like built-in thermal goggles.