There are two comments to make here about how God works in salvation history.
1. God is sovereign
In His great wisdom and infinite understanding, God elects to do the things that He does and we must learn from His dealings with imperfect and incomplete understanding.
2. Different Situations
The situations in Ex 4:23 and Matt 5:38, 39 and quite different and not really comparable. Matthew is discussing a relationship between two humans; Exodus is discussing the relationship between a nation and God. The two could not be much more different - almost opposite ends of the spectrum!
In the Bible we read that God must (because of our humanity) sometimes rube and chasten us in various ways. In the case of Egypt, God sent nine chastening messages before the final, very severe one. Note the way God deals with us at times:
- Ps 39:11 - When you rebuke and discipline anyone for their sin, you consume their wealth like a moth-- surely everyone is but a breath.
- Ps 38:1 - O LORD, do not rebuke me in Your anger or discipline me in Your wrath.
- Heb 12:5 - And you have forgotten the exhortation that addresses you as sons: “My son, do not take lightly the discipline of the Lord, and do not lose heart when He rebukes you.
- Rev 3:19 - Those I love, I rebuke and discipline. Therefore be earnest and repent.
Since God was rebuking and chastening Egypt, it proves that God loved Egypt and its people!! However, they became very stubborn and needed very strong discipline.