It's even better than that. They can be both sexes at once.
I think the thinking is that, being slow-moving sort of animals, and only able to emerge into the open and be active when conditions are just right (ie warm, wet nights), they have to make the most of their limited opportunities for mating.
So each snail is both male and female at the same time. Two snails will get together, attach themselves to each other foot to foot, and then one or both will stab the other with a little horny harpoon carrying a packet of sperm.
Both snails can get their male ends away, while both can also become pregnant and go on to lay eggs. Two sets of genes exchanged, and two sets of eggs laid as a result of just one encounter.