When we kneel down to pray at night to ask God for something, it doesn't mean we can ask God for anything and he will grant it.
God is not a genie who magically grants all our wishes.
Instead, God is a loving Father, who knows what we need, even when we pray for the wrong things.
The Catechism of the Catholic Church explains that God's "jealousy" does not allow him to give us everything we ask for:
"You ask and do not receive, because you ask wrongly, to spend it on your passions." If we ask with a divided heart, we are "adulterers"; God cannot answer us, for he desires our well-being, our life.
If we ask for something that would be harmful to us or to another person, God is not going to grant it.
God loves us and does not want to see our heart pursuing other things. He wants us to pursue him above all things.
Aligning our heart to God's heart
The Catechism goes on to show that when our heart is aligned with God's will, then he will grant our prayers:
"Or do you suppose that it is in vain that the scripture says, 'He yearns jealously over the spirit which he has made to dwell in us?'" That our God is "jealous" for us is the sign of how true his love is. If we enter into the desire of his Spirit, we shall be heard.
The 4th-century monk Evagrius Ponticus gives us some advice, "Do not be troubled if you do not immediately receive from God what you ask him; for he desires to do something even greater for you, while you cling to him in prayer."
St. Augustine also offers us his thoughts on the matter: "God wills that our desire should be exercised in prayer, that we may be able to receive what he is prepared to give."
Often God is working within us through our prayers so that someday we will be ready and willing to receive what he wants to give to us.
It isn't easy to be patient for God's response in prayer. What we need to do is to recognize God's movement in our hearts, accepting the fact that we are the ones who need to change, not God.
If God doesn't answer our prayers in the way that we want, it probably means that there is something within us that needs to be changed.