A long time ago, snakes used to have four legs, but evolution has done away with all but the most vestigial remains of this.

The earlier snakes were probably more like lizards, and had legs.   When snakes started to slither into tunnels and leaf litter in search of prey, millions of years ago, their legs became a hindrance, and eventually withered away.

Today, some snakes, usually pythons and boas, have vestigial remains of hind legs, which appear as tiny spurs on each side of the cloaca.   These are more obvious in male snakes, and may sometimes be felt if you run your finger gently along the underside of the snake near to the cloaca.   In larger snakes, they are more visible.

The spurs are used in mating, to position the female, and to help arouse her.
Spurs on a snake

Spurs on a snake.