How, according to the Catholic Church, can God order genocide even though the Church has declared such a situation impossible? Quoting Veritatis Splendor:


  Reason attests that there are objects of the human act which are by their nature "incapable of being ordered" to God, because they radically contradict the good of the person made in his image. (...) The Second Vatican Council itself, in discussing the respect due to the human person, gives a number of examples of such acts: "Whatever is hostile to life itself, such as any kind of homicide, genocide, abortion, euthanasia and voluntary suicide, (...)"


Veritatis Splendor, 80

So I believe that we can say that according to the teaching of the Catholic Church, genocide can never be ordered to be carried out by God and committing it is always evil.

Still, in the Bible we have examples of GodMoses (see comments) ordering His believers to commit genocide:


  But in the cities of those nations which the LORD, your God, is giving you as your heritage, you shall not leave a single soul alive. You must doom them all - the Hittites, Amorites, Canaanites, Perizzites, Hivites and Jebusites - as the LORD, your God, has commanded you, lest they teach you to make any such abominable offerings as they make to their gods, and you thus sin against the LORD, your God.


Deuteronomy 20, 16-18

This most obviously satisfies the definition of genocide, as stated by the United Nations:


  Genocide is defined in Article 2 of the Convention on the Prevention and Punishment of the Crime of Genocide (1948) as "any of the following acts committed with intent to destroy, in whole or in part, a national, ethnical, racial or religious group, as such: killing members of the group; (...)"


OFFICE OF THE UN SPECIAL ADVISER ON THE PREVENTION OF GENOCIDE (OSAPG)

There seems to be incongruity in Catholic teaching here. How does the Church explain the fact that while it declares it impossible for God to order genocide, such an order from God seems to be described in the Bible?
God makes plenty of commands that are recorded in Holy Scripture. Why would Deut. 20:16-18 be an exception?

The original Douay-Rheims translation of Deut. 20 prefaces this chapter with


  Lawful wars are to be undertaken with courage and confidence.


The war is lawful because it is defensive. It is to defend the people against the great spiritual threats of the idolaters, whom the Lord knows would tempt the people of God to violate the 1st Commandment.