Worms that resemble lengths of thin white cotton wiggling in the water are normally just detritus worms and are harmless, if a bit unsightly and yucky. Many (most?) tanks seem have them (especially those with aqua soils) but they aren't noticed until there's a population explosion for some reason. Assume they've been there for a while and you've only just seen the tank in the right light / right time / etc to notice them. Some fish might find them a yummy meal, removal of food source can help, but I've had an outbreak in a never fed, new setup tank with Amazonia soil. Actually I've had short lived outbreaks in every tank I've setup with Amazonia, but only really noticeable in those tanks without fish to gobble them up! You might find they disappear as quickly as they appeared.