Why did God command Israelite men to put away their unbelieving wives, but Paul said not to do so?

PROBLEM: Ezra made all the returning Israelites put away their “pagan wives” because they were “adding to the guilt of Israel” (Ezra 10:10). However, when Paul was asked whether a believer should divorce an unbelieving spouse, he said, “If any brother has a wife who does not believe, and she is willing to live with him, let him not divorce her” (1 Cor. 7:12). Aren’t these contradictory instructions?

Ezra 10:10 - 44

ESV - 10 And Ezra the priest stood up and said to them, "You have broken faith and married foreign women, and so increased the guilt of Israel.
11 Now then make confession to the Lord, the God of your fathers and do his will. Separate yourselves from the peoples of the land and from the foreign wives.

In my opinion, the two situations are not strictly analogous. By my understanding, Paul (who was the apostle to the Gentiles) was speaking of a situation where neither spouse had been a Christian prior to marriage, but one of the spouses had become a Christian after marriage, while the other one had not. In such a case, the spouse who was now a Christian was not to divorce the non-Christian spouse on that account, provided the non-Christian spouse was willing to continue living with the Christian spouse, since the Christian spouse could be a continual witness to the non-Christian spouse, and might succeed in converting him or her, as well as being a positive spiritual influence on any children the couple might have or have already had. (In addition, as Paul noted in the cited verse, this course of action did not have the same force as a command of God, but was Paul's own personal guidance.)
In Ezra's case, the men involved had already been practicing Jews who had knowingly married non-Jewish women who apparently did not intend to convert to belief in the God of Israel. God had previously forbidden intermarriage between Israelites and other nations (Deuteronomy 7:3), and those men had broken that commandment. It was therefore necessary from the standpoint of obedience to the Law at that time, and for the spiritual restoration of Israel, that those men divorce their unbelieving wives.

Believers are not under OT laws to Israel (Matt. 5:17-18). I appreciate Mr. Maas' comment, "God had previously forbidden intermarriage between Israelites and other nations (Deuteronomy 7:3), and those men had broken that commandment. " -- and I might add that these were not just any pagans, for they included descendants of Moab and Ammon (Ezra 10:30; cf. Neh. 13:23) and other surrounding nations of which God had told the Israelites explicitly that they should not marry them (cf. Ex. 34:16; Deut. 7:3).