The first question: what the worms do on the ground during the flood? One of the answers to this question is -
"It gives them an opportunity to move greater distances across the soil surface than they could do through soil," said Dr. Lowe. "They cannot do this when it is dry because of their moisture requirements."
The second question: why they form ball after moving to the ground. There are two answers to this question:
First, as a part of surviving mechanism to prevent drying. As you can see, they cannot come back to the soil across the asphalt, thus they form balls and wait the weather to improve.
Second reason to form the balls - communication:
"The earthworms use touch to communicate and influence each other's behaviour, according to research published in the journal Ethology.
By doing so the worms collectively decide to travel in the same direction as part of a single herd."