I think it's because when it rains hard, many worms come out so that they don't drown underground. When the rain stops, they start to dry out (which they can't tolerate for long), and they seek moist surroundings again. If they have wandered near your pool while it was raining (especially at night), they sense the moisture from the pool and head for it, eventually falling in and drowning.