I can't comment on other jurisdictions, but the United States has a section of legislation called the Civil Rights Act Title VII[1] codifying that discrimination on the basis of a variety of factors (age included) is actually not (legally) right.
I think this is hard to enforce in practice, but just to be clear -- it's not (technically) "right" to be ageist in one's hiring practices in the US.
We have similar anti-discriminatory rules in the various parts of eu.
The answer is always: 'prove the discrimination'.
Candidates can rarely afford to even consider bringing a case.
Sure it does. It may suck from a perspective of a candidate, but it’s a fair business position to value cohesion in a team.