There must have been pest snails in with the fish you bought. While they most commonly come in on plants they can come in with fish. Same must have happened to me recently, all i added was some guppies and some shrimp, and a few days later pest snails started appearing.
Once they are in your tank they will be difficult to get rid of. Squish them when you see them. You can create a snail trap and remove the ones that get caught. There are chemical treatments that will kill invertebrates, but they cant distinguish between pest snails you want to kill and any shrimp or snails you want to keep. The copper in these treatments are difficult to remove, so once you have treated the tank, it will probably kill any invertebrates you may want to add in the future. Assassin snails will kill and eat them, and there are fish that like to eat snails too, like a yoyo loach.
But really, once they are in the tank, apart from chemical treatment, you wont permanently get rid of them. If there are snails there will be more snails than the ones you have spotted, there will be eggs, and eggs lead to more snails. They will be in your filtration, hidden in your aquascape etc. So really, its just about controling numbers. Squish them when you see them, trap them out if you want, avoid overfeeding your fish so there isnt excess food to support lots of pest snails.
They are harmless.