I don't think anyone here thinks it should be correct, but apparently the authorities have decided that is a deliberate action. He deliberately headed the ball that's for sure. It didn't go where he wanted it to, either cleared forwards or back to the keeper.
It's this vagueness that allows for interpretation. Rules shouldn't really by interpretable in different ways.
Salah's presence brings in another clause as mentioned by @ThunderPower_14 above, and yes probably should have been invoked in this case. Again, open to interpretation.
Would it really be so bad to forget any interfering with play and deliberate actions and just call an offside if any player is in an offside position? Did many goals used to get ruled out for this when someone was just stood up by the corner flag for example?
The most common situation I can think of ithat this would affect is when an attacker who isn't going to receive the first ball stands well offside from a free kick that will be crossed into the box, and it might even be better if that were eliminated - this is a problem for the defending team in that they are essentially not allowed to mark a player during the first phase of play.
Players would just have to quickly learn to always be onside, but all grey areas would be removed.