How do the worms move? Do they glide across the surface/glass or do they inch? If they glide across, they are probably planaria. There are many different kinds out there. If they inch across like a slinky, it's probably a leech. We always wonder where these things come from, but introduction could have been very early on when we received our plants and weren't too careful about sterilizing/quarantining them. Down the line, they could pop up when you move the plants or reuse anything from an old tank, including the filter.