Just found this on another website;
The good news is that those little critters are totally harmless to your fish. They are a type of planaria and are simply feeding on excess waste in the tank. The bad news is the reason they are thriving in your tank is that you've been overfeeding. Medications and chemicals have little effect on planaria. Planaria freaked me out too the first time I saw them in an overfed guppy tank many years ago. They survived even a bleach treatment on the whole tank (I took the fish out first of course). Planaria have to be "starved out". They don't touch your fish so don't worry about that.
The first thing to do is cut back on feeding the fish. Cut back by 50%. The rule of thumb in feeding fish is that whatever food you put in the tank must be totally consumed from all areas of the tank in 2 to 5 minutes. If you feed twice a day, it's 2 minutes. If you feed once a day it's about 5 minutes. The goal is to allow the fish about 5 minutes of actual eating time per day. If there is any food floating around or on the bottom of the tank or on the decorations after that time, you are overfeeding. Even if the fish eat all the food eventually it is just too much for them to digest properly so they produce more waste and eating too much could also make the fish sick.
The one thing you want to try to avoid is cleaning the whole tank out. Your fish will have to suffer through another episode of new tank syndrome if that happens. It's pretty stressful for them and some or all may die. You should be making water changes and vacuuming the gravel now though. Replace 25% of the water right away and vacuum the gravel lightly. Do a 25% water change every week but only vacuum the gravel every 2 to 4 weeks. That schedule is normal for any tank, no matter what kind of fish you have.
You may see more planaria for a little while as they come out of their hiding places to look for more food. They aren't increasing in numbers, just easier to see. They will die off and the fish may even eat some. It's good for your fish to do that. It's natural live food they would seek out under normal circumstances. Since the fish were so well fed, they just didn't care to do that.