No there not dangerous, some fish do eat them, it means you are over feeding, or not giving the gravel a good vac.
Not the writer of this informtion below.
There are loads of tiny transparent worms on the glass of my freshwater tank, especially near the water surface. What are they?
They're planarians - a type of turbellarian flatworm, found in tropical and coldwater aquaria. They generally live in the substrate, feeding on dead and decaying organic materials. Although they are not harmful to fish their presence in high numbers suggests that you are overfeeding and under-maintaining your tank.
Test the water and improve general maintenance by gravel cleaning more regularly and cutting down on the amount of food you offer.