Hardening the heart is an Egyptian expression…
The Egyptians, like most of the peoples and like a lot of the Jews, did plenty of evil things in daily life, as a country. If God wanted to condemn them to death, He has a right to do it. He did not always choose to do it, because He had plans to help everyone. But if a people could have reined in their king and didn’t, they were partly at fault.
Pharaoh was in charge, so he was the most worthy of punishment. Pharaoh called himself a god although knowing he was not, so God included him in his campaign of plagues against the Egyptian false gods.
God demonstrated to Pharaoh that he was in fact weak and powerless, that his people were his only power and that he needed to care for them instead of mistreating them, and gave him a reality check.
This did not end the custom of calling pharaohs gods, unfortunately, but it ensured that the leaders and kings of Israel and Judah never played that stupid game, even though many of their neighbors in Canaan did.
The thing is that the Promised Land is snack dab in the middle of enemies. Egypt was not all that expansionist, but they did expand at times. They could have made Israel an Egyptian province with Egyptian gods. But Egyptians also hated to record or think about defeats and misfortunes. Associating Israel with all sorts of terrible smiting, by a god more powerful than Pharaoh or the major gods, made Israel safe from Egypt for a long time.