Of course people are taught what a hate crime is.
But whether someone is killed because they are in a protected group or whether it is a so-called 'motiveless killing' doesn't matter - any murder is a tragedy for all concerned, and for society too - As John Donne said, '. . .any man's death diminishes me/because I am involved in mankind'.
I don't know what can be done about it. Capital punishment doesn't work. There is education in place that teaches children that killing is wrong. There is already a penalty for carrying knives. I suspect that if drugs were legalised gangs would spring up around a different 'cause' (for want of a better word). Also, there are people killed for just looking at someone the wrong way in the pub, and for choosing the wrong underpass to cross the road at night - they could have done nothing to stop it. It seems to be something that is part of the human condition, but luckily there are more people who abhor violence than those who commit it. On the whole, the UK is a safe place to live, and murder by strangers is mercifully rare.