Deuteronomy 7:2 only applies to the Hittites, Girgashites, Amorites, Canaanites, Perizzites, Hivites, and the Jebusites, and none of them exist anymore.
Deuteronomy 6:18, on the other hand, demands that the Jews "Do what is right and good in the LORD's sight, so that it may go well..."
What is right, and necessary, is to kill the enemy. Before he kills you, if that’s his intention . Any responsible government has this DUTY to its citizens, indeed this is the primary responsibility and purpose of government.