If they are thread-like and all the same width from head to tail, they are probably detritus worms. Especially if you can see little segments if you look very closely. They will seem somewhat blue in the light. If you get some magnification going, they usually have cilia, that is, fine hair like projections down their bodies. Sometimes you see them in the water column squiggling around like they have no idea how swimming works. On the glass, they inch like earthworms. They are more common in new tanks. They are just eating junk, they are harmless and usually subside as the tank matures. Thin them out faster by avoiding over feeding.
These are detritus worms
Planaria are fatter at the head and there are numerous species. Some are harmful, most are not. They are a group of flatworms and are actually food for a lot of fish.
They also happen in new or overfed tanks. This is a planaria
TL;DR they are very likely harmless. Don't over feed. Both species are often eaten by smaller fish. Wait them out if it's a new tank.