Many employers have employee referral programs (a.k.a. "ERP") which reward workers for sending good job candidates, if the candidates are hired and remain to get a given amount of time specific to that company. This question may be part of this qualification process, confirming and documenting the referral.
Often this question is asked so the company can understand which platform or recruiting approach being used is the best. When the employer recognizes what is working vs. what isn't, they can correct and alter to use the most successful strategy for their recruiting.