Is this the official Catholic teaching on the subject though?
This would be my take on the subject.
If we are speaking of the three omni- Creator and sustainer of the universe and of all that is within it, as the speaker of the words attributed to him in the Old Testament, then presumably the eternal, omniscient, omnipotent, omnibenevolent God would have access to knowledge about every human being subject to those commands and the repercussions of carrying out those commands down through all of history and into eternity.
That would mean we, as very limited, very naive, human beings with a very limited slice of knowledge of the entirety of existence, and with very feeble and faulty moral consciences, are in no position to provide oversight to God on what infinite goodness, omniscience and omnipotence would command in any particular circumstance.
It would be silly to even venture a moral opinion precisely because the final authority on an moral matter would be the omnibenevolent, omnipotent, omniscience Creator, if such exists, and not feeble, ignorant and morally decrepit beings such as us.
Ergo, if God exists we are in no position to speak our opinion regarding what he commands.
If God does not exist then clearly he couldn’t have commanded any of it.
The problem is that we cannot argue FROM the supposed divine commands TO the non-existence of God, because if the commands were legitimately Divine commands they would be unimpeachable, and if they were not, the answer is moot to begin with.
So the entire question rests on the prior establishment of the existence or non-existence of God and from there we can move to possibly consider whether those particular commands came from the mouth of God.