Snails often come with plants and sometimes in the water with fish or on decor from another tank.
I don't consider snails a pest at all, but rather like algae, they are an essential part of an 'almost' natural eco-system. (I use the word almost because any of our attempts to match nature is only close as we simply can't completely duplicate all of the miriales of nature in our tiny tanks.)
I have hundreds of Malaysian Trumpet Snails (started with just 12!) in my 60g. There are numerous pond type snails in my 10g. The population of snails can be self regulating based on food. In the meantime, they are part of the cleanup crew helping to process and breakdown excessive waste materials.