Most likely Planaria. You can get rid of them by being careful not to overfeed and keeping the gravel clean.
Do the worms live in the substrate minly, only getting stirred up as you say, or do you see them in the water free swimming and or on the glass? If not planaria, they could be nematodes.