In these passages, God tells Ezekiel a very important Truth. God says that if a wicked person who is steeped in sin dies in that state, then that person will die spiritually. In other words, he or she will go to Hell. On the other hand, a person who is righteous and dies while being righteous will live, spiritually. In other words, he or she will go to Heaven.
However, if a righteous person turns from his or her righteousness and becomes a wicked person and then dies while being wicked, that person will die spiritually and go to Hell. God will not remember his or her former good deeds.
On the other hand, if a wicked person turns from being wicked and becomes righteous and dies while being righteous, that person will live spiritually. God will forget his or her former wicked deeds. Therefore it is critically important how we finish our lives.
The person we are when we die will determine whether we go to Heaven or to Hell. That is why it is wrong to assume that our salvation is assured when we first believe in Jesus. We will always have the freedom to choose and be capable of turning away from believing and trusting in Jesus. If we turn away from that belief and then die, we will not go to Heaven. We will go to Hell.