In the magazine case you are taking out an advertisement with no ability to discriminate. In the Facebook case there is a specific setting based on age to show job ads. Job seekers over the age of 40 are protected so this is discrimination against a protected class. The problem is not that young people were targeted, the problem is that those over 40 were not.