Almost defininate they are planaria, most tanks have some at least in the filter. they are harmless but a bit ugly,
they feed on leftover food and fish waste, keeping up on tank maintainance will get rid of most of them, especially good gravel vacs, including under the edges of decorations.
They will not hurt your fish.