There are several reasons why product pilling happens. It's usually either;
1. not waiting long enough to allow product to fully absorb before applying the next product
2. products are incompatible with each other. Usually with primer-foundation, they need to be the same type (silicone based primer with silicone based foundation or water-based primer with water-based foundation) for them to work well together and prevent pilling, although it isn't always the case
Try waiting a few minutes in between products to let them absorb to see if that could solve the issue.
But personally, I would ditch primer and just wear the foundation without it. Primers aren't necessary and can be quite a hassle to find one that is compatible with both your skin and foundation.