My headcanon is that Zygarde was looking for trainers to help it fight off the UBs. Notice how the cores are found in houses, including the player's and two Kahunas(Olivia and Hala)? Once the player started gathering cells, Zygarde figured it may as well go with the payer.