The Ramban strongly criticized Abraham for leaving the Holy Land during a famine, and cited that episode as the reason for the Jews' enslavement in Egypt:
And you should know that our father Abraham committed a great sin unintentionally, when he brought his righteous wife to stumble into sin because of his fear of getting killed. He should have trusted God to have saved him, his wife and all that was his... God would [also] have saved him from dying in the famine. And because of this deed it was decreed that his seed would be in exile in Egypt under the hand of Pharaoh. [Ramban on Genesis 12:10]
But Abraham's son Isaac almost did the same, but God told him not to:
There was a famine in the land -- aside from the previous famine that had occurred in the days of Abraham -- and Isaac went to Abimelech, king of the Philistines, in Gerar. The Lord had appeared to him and said, “Do not go down to Egypt. Stay in the land which I point out to you. Reside in this land, and I will be with you and bless you. I will assign all these lands to you and to your heirs, fulfilling the oath that I swore to your father Abraham." [Gen. 26:1-2]
Then Isaac's son Jacob did the same. [Gen. 46:6]
So why did God explicitly prevent Isaac from going to Egypt, but not his father Abraham or his son Jacob?