One thing you might be interested in reading about is Disparate Impact. Discrimination cases can be proven by showing that a practice has a disproportionately adverse impact on members of a protected class, even in the absence of intentional discrimination.
The Supreme Court noted in Griggs v. Duke Power Co that the Civil Rights Act bans "not only overt discrimination but also practices that are fair in form, but discriminatory in operation." In fact, "absence of discriminatory intent does not redeem employment procedures" that operate in a discriminatory manner. Unintentional discrimination is still discrimination.
In a piece on age-based discrimination, Facebook said, "age-based targeting for employment purposes is an accepted industry practice and for good reason: it helps employers recruit and people of all ages find work." (https://www.propublica.org/article/facebook-ads-age-discrimi...).
I think a lot of the industry has been casual about job ads, but Facebook is kinda the first platform that really lets you be exact with a lot of your targeting. Before, maybe you feign ignorance that "Men's Health" doesn't have a lot of women readers. Plus, women can read Men's Health. However, I can't get Facebook ads targeted to a different gender. Facebook lets you be reasonably exacting.
If I create a Facebook ad for a job application with no other promotion of the opening (including on my company's website) and target it just to men, is that discriminatory? IANAL, but in Griggs the court held that procedures that act as built-in headwinds for protected groups are illegal. Making it so that women could only hear about the job from a man seems like quite a headwind working against their likelihood of getting the job. Griggs is about job qualifications that were used as a proxy to keep black workers from getting jobs, but making it so that a group of potential workers can't even see the job application seems similar.
Going back to your example: if someone used a gender proxy like "people who like action movies", I think it would be hard to defend in court. 1) They don't need to prove discriminatory intent, just disparate impact. 2) It seems likely that a company adopting such targeting would have communication indicating their discriminatory intent. "Facebook won't let us target by gender anymore! What can we do?" "Let's use things like action movies to get the same result!" If that comes out in discovery, it would seem like a simple case. 3) At some point, a court is going to want to know what the basis of that targeting was and it's going to sound really hollow. But it doesn't even matter if they come up with a good cover story, because even if it was unintentional, it can still fall afoul of the law.
On the other hand, if I run a tech company and wanted to target "people you are into the Python programming language", that's a group that will likely skew male, but it kinda passes a sniff-test. It just doesn't smell funny. "Yeah, um, we want programmers and I thought targeting people into Python was reasonable." That does sound reasonable. It's not meant as a proxy for gender, but for an interest/skill that is closely related to the job. Action movies aren't related to my job, but a programming language is.
Going back to the magazines: I think much of the same might apply, but I'm guessing that we've been relatively lax about it as a society. It might not feel inherently discriminatory, but disparate impact doesn't rely on intentional discrimination. You say, "that's just how advertising works," but you could easily place ads in multiple places to reach a wide variety of people. One program might not reflect the population at large, but I don't think it's rocket science to advertise in multiple places to reach a more representative sample.
As I noted above, Facebook says that job targeting (at least on age) is an accepted industry practice. There are people that don't like the disparate impact theory (though it is established Supreme Court precedent since 1971). Plus, I don't know if disparate impact has ever been used in terms of narrowing the field before applications even come in. In Griggs, the procedure disproprotionately weeded out black applicants. In the Facebook case, those potential applicants never even knew the job existed.
I have definitely thought the same things you've thought. Society is hard. Fairness is hard. But I think it's important that we work toward fairness. This isn't meant to be anti-company. I just think companies should have a bit of a justification for doing something if it runs contrary to fairness. If you're only advertising your programming jobs to people under 40, why? If the answer is, "we mostly don't want to hire older programmers, but if a good one happens to come along we'll take them", that doesn't feel like a great justification. In fact, it basically admits discrimination. If the answer is, "there are more young programmers than old programmers", I think the retort has to be, "given the loads of ways you can target, why not target based on interests rather than age or gender? Targeting to people interested in CS, various programming languages, etc. seems both better for you and for potential applicants...unless you're trying to discriminate." It's not always simple, straight-forward, or easy, but I think we're trying to build a better, more fair society and that requires hard-work and questioning.