On the one hand: it's completely irrational to think like this.
On the other: fearing for your life one moment and then facing tragic outcomes the next, can really torture one's psyche. People do irrational things when pushed past their limits/tolerances. That includes indulging in the just world fallacy in order to make sense of things.
Why indulge in irrationality at a time like this? Because the alternative is unthinkable in the moment and exposes you to survivor's guilt, grief, despair, depression, the reality of a random & uncaring universe, and more waiting for you in the end. And it just so happens that the church is often the only psychological support structure folks have, so we get god-fearing advice like in OP's meme.
As much of an oxymoron as it sounds, I see things like this and think that an "atheist ministry" could do people a lot of good.