When retreating, your fleet can end up in multiple systems. If you then try to move the fleet it will not all gather, but each system will stay together and the fleet jumps separately instead of gathering at the ships closest to the target, then jumping together. This results in the fleet tricking in to the next target system. The logic here is probably treating ships in other systems as just built so ignoring them for gathering, but this is a case where there needs to be a distinction. After retreating the ships need to regather (or all retreat to the same place if set to move in formation).