If they spend all their time on the glass then they eat film algae. Ones that eat coral, stay with the coral they eat (and lay their eggs there). Ones that are photosynthetic (red planaria), spread out on all the surfaces and upper glass to catch light. My non-scientific 2 cents.
If any flatworm is questionable (and your fish don't eat it), or it simply bothers you, suck it out.