Let’s answer the question in two parts.
Examples from the Bible show that people understood that prayer would change God’s mind. One such example is King Hezekiah of Judah who was told by God through Isaiah the prophet that he was about to die (Isaiah 38:1-8; 2 Kings 20:1-11). Hezekiah prayed urgently for a change of plans (2 Kings 20:2-3), and before Isaiah had left the palace God sent an answer saying that Hezekiah would not die for another 15 years (2 Kings 20:4, 6). As far as Hezekiah was concerned, prayer had caused God to change his mind.
This is the easy part of the answer! The second part of the answer is a little more complicated.
God announces that he knows the end from the beginning (Isaiah 46:9-11) and also that he does not change (Numbers 23:19). How does this fit with God’s positive answers to prayers which ask for a change to his stated plans?
The answer is probably found in the fact that, as humans, we do not know the future, so God sometimes presents things to us as though they will happen, when he knows that they will not. Our responses are then based on what is presented to us. We may then pray and the situation seems to change. As far as we are concerned, God has changed his plans – although with his knowledge of the future, none of God’s plans changed at all. All we have done is caught up with some of God’s knowledge of the future.
Hezekiah was told that he would die, although God already knew that he would pray and that he would be told the death sentence had been delayed. God probably presents answers to prayers as God changing his mind because we do change our minds about things — this is something we can understand. God wants to develop our character and this is sometimes best done through testing us as he tested Hezekiah. Would we pray to God if we knew we were going to die? We can’t know for sure until it happens to us. Would Peter have denied he knew Jesus? He was sure he wouldn’t until it happened, and then he learned some important lessons. From our point of view, God changes his mind in answer to our prayers. When his knowledge of the future is taken into account, however, there is only a change in the information available to us – we have moved further along a path God has prepared for us to walk (Ephesians 1:4-5; 2:10).
If this second part of the answer is too confusing, take the first part and keep praying to God — he is a God who answers prayer and he will never leave you or forsake you.