The three of a kind is in the community cards, so everyone has it. In that case it goes to whoever has the highest spare card, the ace in this case.
OK, but it should have gone to Fluttershy, with the AQ, whereas it clearly went to Pinkie with the AJ.