But do "righteous" people really know that, or are they just using their imagination? And if they really actually know that, then how do they know that?
It's known because it is experienced. And furthermore, it produces tangible visible changes or effects. The quality of life experienced is radically changed, and everything done in that life has tangible and lasting differences in the material world. There is a saying that "Imagination becomes reality". This is very true.
Imagination, or inspiration is what opens us to the possible beyond the seen. It is what has created civilization. It is what moves us beyond our mere animalistic impulses. It is what moves us beyond our isolated and separated sense of self, into Awakening, or connection with the Divine. It inspires us towards action, through visualization. And if that visualization is of Ultimate Good, that has an tangilbe, life-giving energy that is connected to all living things. So "prayer" in that sense is "upward" or towards positivity, which then transforms that perception of reality into life-affirming, and transforming power.
The opposite is also true. If we imagine ourselves as isolated, and disconnected, or visualize things like paying back others through our anger, that is imagining negative, life-denying energy. And that to becomes a real, lived, experienced reality, through things like broken relationship, ill-health physically, and generally a path towards dissolution and death. So in both cases, "imagination becomes reality.".