Is it considered normal to publish job offers inviting candidates to apply based on their gender and/or race in academia? I was browsing PhD position offers in Europe on different websites and I was quite surprised to find that several offers contained sentences such as


  University of X value equality and diversity. We strongly encourage women and BAME applicants for this position. 


where BAME stands for Black, Asian and Minority Ethnicities; or


  The research group aims to increase the number of women in scientific positions. Female candidates are therefore encouraged to apply.


Is it considered normal in the academic environment to discriminate between  candidates according to their race and/or gender for "egalitarian" reasons? 

How is the choice of a candidate based on their gender and/or race considered "egalitarian"?
These statements, in many variations are quite common. But they are not discriminatory, as you suggest (universities do not "discriminate against white males"). All the statement is saying -- and that is true in actual practice in the discussions of hiring committees -- is that women and other minorities are specifically encouraged to apply. This does not imply that they get special treatment or preference. It is simply a reaction to the fact (statistically proven by research) that women rarely apply for jobs that they do not perceive as a "perfect fit" whereas men do. So if a committee has a bunch of applicants where none is a perfect fit, more often than not a man is hired because there simply are not enough women in the pool.

See: Why Women Don’t Apply for Jobs Unless They’re 100% Qualified.



I do want to also comment on one of your comments while we're here. You state 


  I think job offers should only focus on the candidate's skills regardless of his background and gender.


That is true, but how do you define "skills"? Let's use "qualification" instead. If you're, say, a typical math department where 50% of undergraduates are women, 35% of graduate students are women, but only 20% of tenure-track faculty are women, wouldn't part of the qualifications you are looking for in an applicant be that that person is a good mentor to many of the students in your department? Does it not diminish the quality of the department in its ability to teach and mentor if every single faculty was a white male? It is important to recognize that the role of the faculty extends beyond just writing papers in obscure journals; "qualification" is a term that ought to be understood much more broadly than you may think.

(I think it's important to say that the role of women in math departments is not to be there as mentors. All I want to say is that I want diversity to be part of the many considerations when deciding who is "best qualified" for a job.)