It's both. A combination of hopelessness for their future and an ideology that can be seized upon to fill that same void.
50 virgins in the afterlife is the simplest example of this. Whom might such a future appeal to? Not so much the successful family man, I think. But it's not the only ideology that fits the bill. If you can promise any kind of wider purpose to someone's life (e.g. save your race!) that'll inherently appeal to a portion of the people that feel their life lacks meaning. If that group gets bigger AND an ideology gets increasing mind-share, you get the phenomenon we're now experiencing.
And it has nothing to do with dude "having no prospects". That people in this state then fit greatly into ideological bubble that feeds their delusions is something we can criticize ideological bubble for.
And sure, counter-examples exist, though that particular one isn't really in the same space as this. Certainly people kill each other, and sometimes crazy people kill random strangers. But that was not a mass killing in the sense that this El Paso situation was, or that 9/11 was.
I don't want to spread any more content about him by sharing links or quotes here, but I think it's important to dispel the suggestion that he had a well-functioning social or relationship life.
Media interviews with people who knew of him all indicate that suggestion is false.