Hello; Look like a round worm more than a flatworm planaria. altums85's response is from experience so should have a lot of confidence attached. May or may not be harmful but not something I would not want in a tank. I would likely sanitize the entire tank. I would likely try to soak the tank with all the equipment used in the tank, the substrate, nets and all with a Clorox solution. When a clorox soak is finished with the tank, substrate and all rinsed, it is necessary to use some water treatment such as SAFE or Prime before putting the fish back into the tank I have used Prime.
The fish will have to be put into another container during the clorox soak. Likely take a very good look to see if any of the worms are attached to the fish. Might be on the gills which will be hard to see in small fish. An approach could be to have the fish in a bare tank with no decor or substrate which might make seeing the worms easier. I am largely guessing here so take the suggestions with a lot of grains of salt.
The clorox soak will kill snails so perhaps catch a few snails and put them into a container in a quarantine sort of approach. If after a time the snails seem clear of the worms add them to the newly set up tank. I would consider killing all the snails and getting other snails to replace them. Not a situation I have personal experience with so keep such in mind.