Holy fucking shit dude. Press Ctrl + I in the game and stack that empire tree. Or just click the corresponding button in the top left of the HUD on the right of the Search button.
To answer your question:
Each time the pirates clear a planet, the remaining ships that survived the sweep of the gravity well will return to their Pirate Base (the one present in the system where the raid took place). Since you were continually being attacked by the pirates the AI players probably sent the pirates on missions to attack you, which explains why you were being attacked in so many different gravity wells.
The more succesful raids take place, the harder it becomes in the end to wipe out the pirate base. If you would select all the pirate ships in the Pirate base gravity well you would most likely see a huge amount of different fleets in the upper section of your empire tree. Each fleet represents a succesful raid.