These passages give us a theological basis for God doing these things to the Amorites and the Amalekites and others. Paul's overall argument is that God is justified in what He does. I mean, that is pretty simple. God is justified in what He does. He does not do anything wrong. He does not do anything that is unfair or unrighteous. He is God! He sets all the rules. He lives by those rules. He has perfect character. Not only that, He is the Creator. He made us all. He made everything. He made His law known.
In addition, because He is God, He is sovereign over all things, He can choose or prepare certain peoples to bring about His plan of redemption. He can choose them to be vessels of mercy and honor, or He can choose them to be vessels of wrath or dishonor. He is God. He can choose whomever He wants. He can enlighten some, He can harden others. And He does this in righteousness according to His holy character, and no one has standing to gainsay His decisions. You have no argument against what He does if He is acting as Judge and He judges righteously and fairly.