I don’t think, looking for a motive is always to legitimize the event. We just have a tendency to look for a motive, so we can feel safer that it won’t happen to us.
For example, if she had a crazed boyfriend, then we don’t have the same boyfriend so it won’t happen to us. If it’s a psycho who just picked on her, then it could happen to us.
But in the cases of crazed Muslims who hate all non-Muslims, the media does its best to cover up this motive.
Exactly. Or we look for something the victim of a crime/accident/tragedy could have done differently, or some way we are different ("My child can't drown in the hot tub because we don't have a hot tub."), because it makes us feel a little safer.
It's not "blaming the victim" per se, just a psychological defense mechanism against entropy.