Are you playing vanilla? If you are, don't bother with colonies late game till you have a death fleet, and never selling blueprints on the blackmarket, otherwise you will die to pirates.
The issue in Vanilla is the Player is the ONLY PERSON in the ENTIRE SECTOR that does base bounties, which means, if you never take out pirate bases, they will grow to maximum fleets and defense, and will use the latest blueprints they have available. This means if you sold them a Paragon blueprint and have a max level pirate base near your colony star system? Be prepared to get owned by a death fleet with paragons in it when they raid.
You can fix this by either destroying pirate bases periodically (when they get bounties on them or else its unprofitable) or constantly raiding pirate bases (which destabilizes them after a while while giving you free loot).
That or use mods like Nexerelin, which have factions send out base strikes on pirate bases periodically to keep them from getting too big (and you can do this with your own faction as well).
But yeah, you probably got destroyed by a start of game pirate base you didn't destroy which has grown to max level and has capital ships in its fleets due to that.