In hearing our prayer God does not change His will or action in our regard, but simply puts into effect what He had eternally decreed in view of our prayer. This He may do directly without the intervention of any secondary cause as when He imparts to us some supernatural gift, such as actual grace, or indirectly, when He bestows some natural gift. In this latter case He directs by His Providence the natural causes which contribute to the effect desired, whether they be moral or free agents, such as men; or some moral and others not, but physical and not free; or, again, when none of them is free. Finally, by miraculous intervention, and without employing any of these causes, He can produce the effect prayed for.
The use or habit of prayer redounds to our advantage in many ways. Besides obtaining the gifts and graces we need, the very process elevates our mind and heart to a knowledge and love of Divine things, greater confidence in God, and other precious sentiments. Indeed, so numerous and so helpful are these effects of prayer that they compensate us, even when the special object of our prayer is not granted. Often they are of far greater benefit than what we ask for. Nothing that we might obtain in answer to our prayer could exceed in value the familiar converse with God in which prayer consists.
In addition to these effects of prayer, we may (de congruo) merit by it restoration to grace, if we are in sin; new inspirations of grace, increase of sanctifying grace, and satisfy for the temporal punishment due to sin. Signal as all these benefits are, they are only incidental to the proper effect of prayer due to its impetratory power based on the infallible promise of God, "Ask, and it shall be given you; seek, and you shall find: knock, and it shall be opened to you" (Matthew 7:7); "Therefore I say unto you, all things whatsoever you ask when ye pray, believe that you shall receive" (Mark 11:24 — see also Luke 11:11; John 16:24, as well as innumerable assurances to this effect in the Old Testament).
New Catholic Dictionary