Pirates always attack the player with the highest bounty at the time of the raid launch. The severity of the pirate force depends mostly on the amount of bounty total, but also some minor factors like the number of that player's colonies and trade ships.
The secondary effect of bounty is that it is assigned and distributed among the target player's units, buildings, and planets proportionally (so a planet will get a bigger chunk of the bounty than a teensy ship). Others attacking the bounty'd player will collect the portion of the bounty assigned to the units they destroy. You cannot collect bounty that you yourself put, however - there are several techs that deal with bounty that would leave it wide open to exploitation and getting free credits.
Not overly complicated
Hope it helps!