They "hitchhike" in on things you put in the tank - it could come in on just about anything: rock, sand, coral, macroalgae, even snail shells and such.
Some things are much more likely vessels for them to come in on than others (fish, for example, would be an extremely unlikely vessel for worms to hitchhike in on), but just about anything wet could potentially carry them (or other hitchhikers) in.