I assume OP was some troll, but it's obvious as to why people do things like that: It's because they want to induce that misery in people. A mere "directionless" person without anger or frustration probably wouldn't want to do a mass attack. It's people who want to "get back" at society in the aggregate by causing as much physical and psychological damage to the collective as possible. Of course, this lashing out often leads to the person's death, but there is a clear goal to it, and it is often done by disadvantaged people like high school dropouts such as Ramos, Cruz, Steinhauser, etc.
This explains many untargeted attacks by non-political killers.