I think the idea is that if they have the same chemical composition this is good evidence that they formed from the same primordial gas cloud. If they just happened to be passing by each other, there would be no reason for the composition to be so similar.