The worm isn’t hearing the thump it’s feeling the vibrations.

And as far as curling, it doesn’t gotta do shit. It’s made up.

Hearing is ‘feeling vibrations’
Okay well the worms can’t hear anyway cause they don’t have ears.
Earless worms ‘listen’ through their skin

A common model species can sense sound waves without ears, providing a new tool for studying auditory sensation.

Life Sciences Institute