Facebook has an API (google it) that allows customers (and no, that is not you, Facebook user - it is advertisers, political campaigns, etc.) that allows programmers to write code against all Facebook profile data (thats you, Facebook user, your profile - all the info you gave them including your Likes and Dislikes, ad infinitum).
This API is open to anyone who is buying Facebook product - that is, user profile data.
Some programmers write better code than others to hitch up to the API.
Cambridge Analytics just did it better.