Was it punishment or was it warning and instruction? I don't see where God punished either of them.
As opposed to God's appointed prophet tricking people*Did God tell Abraham to deceive Abimelech?
*See Abraham and Pharaoh
*See Abraham and Abimelech
God punished both Pharaoh and Abimelech because of Abraham's deceit.
Genesis chapter 20, verses 17 and 18 (from the NIV, because I have one next to me): "Then Abraham prayed to God, and God healed Abimelech, his wife and his slave girls so they could have children again, for the LORD had closed up every womb in Abimelech's household because of Abraham's wife Sarah."
Genesis chapter 12, verse 17: "But the LORD inflicted serious diseases on Pharaoh and his household because of Abram's wife Sarai."
Unless, of course, you don't think having the wombs of all the women around you "closed up," nor having "serious diseases" inflicted upon your entire household are punishments.
Also, how was it "warning or instruction"? In the case in Egypt, Abram and Sarai lied and said they were siblings, instead of spouses. This resulted, evidently, in Pharaoh wanting to take Sarai for his wife. There's no indication that Pharaoh would have taken Sarai as his wife had he known she was Abram's wife.
In the case of Abimilech, God did warn Abimilech in a dream, that Sarah was Abraham's wife, before anything happened. At which point Abimilech immediately decided to return Sarah to Abraham, and yet God also closed up the womb of his wife.