Perhaps only a prison psychologist will find out, but I'd think it likely that the mosque shooter was given the idea by the strident islamophobia in the air all around him, not least of which is online in various forms. Why on earth else would he pick the target he did?