Does God change His mind? No, the Lord doesn’t change. Does God know the future perfectly? Absolutely, our Father knows everything, both real and possible, through infinite knowledge and wisdom. Does God lie? God will not be untrue to His righteous character.
If all of this is true, then why does God respond to Hezekiah’s prayer by seemingly changing His mind, or appearing to have been less than forthright with Hezekiah in warning his impending death? How God could have been sincere in warning Hezekiah about imminent death while also knowing that Hezekiah would pray, leading to longer life, is beyond my understanding; God’s secret counsel is always hidden to us. What I can say is that God could genuinely communicate that Hezekiah’s time was up while also choosing to respond in mercy to Hezekiah’s request without having to give away any of the essentials (i.e. God’s immutability, righteousness, and omniscience).
How do I reconcile this? One possibility among many is that God could tell Hezekiah “you will not recover” (Isaiah 38:1) without actually saying, “unless you pray earnestly for recovery” because Hezekiah should know the possibility of God’s mercy. Hezekiah plainly believed that God would consider his plea, thus it is reasonable to assert that God’s openness in giving Hezekiah further days is implied even in the act of communicating through Isaiah.
Whatever explanation you find most satisfactory, doctrines about God must take seriously the entire scope of scripture. When God relates to us in time and space in ways that confuse us, study the text more rigorously, consult theologians sincerely, and seek the counsel of believing friends humbly. Such is how we grow in understanding God through sacred scripture.