These worms are harmless. They usually multiply in response to the amount of decaying matter you have in the tank. At least that is what I have read on another forum years ago. I used to get them also. I would also get long, mud tubes on these same tanks.
I only have one tank now, and three fairly good sized fish. No gravel. Only plastic plants. Until recently, all it had were three hydrosponge filters for filtration. About two years ago, I started feeding frozen foods. I also introduced a new fish into the tank. A few weeks later, I saw a bunch of these worms. I knew they were harmless from past experience, however, I did not like having them. So, I treated with a fairly strong medication (I forgot which). I never changed the water and kept the medication in the tank until the water change a couple of weeks later. It stained the silicone. I had no carbon filtration. If I remember correctly, the water turned blue. And, it was a medication for cooler water fishes like goldfishes. Anyway, the worms went away. I do not overfeed. I have not seen a trace of them since.
My personal preference is not to have them. Someone told me that they might be tubifex worms. I don't really know. But I did get rid of them, for good.
One more thing. I think the worms responded to the medication by building tubes. At least the amount of mud tubes multiplied when I added the medication. I used one of the plastic plants to scrape the sides and bottom of the tank to break up the mud tubes.