The Catholic Church DOES NOT teach that God chooses the Pope.
https://www.bing.com/search?q=does+the+Holy+Spirit+choose+the+pope%3F
You are absolutely correct. It is the ecclesiastical and spiritual version of GIGO: Garbage In (electors), Garbage Out (electee).
God and the Church, however, provide a remedy in advance for that, at least from apostasy, heresy and schism which separate one from Christ, the Catholic Faith, and the Catholic Church BY ONE'S OWN ACTIONS.
Cum Ex Apostolatus Officio, Apostolic Constitution of His Holiness Pope Paul IV, February 15, 1559.
6. In addition, [by this Our Constitution, which is to remain valid in perpetuity We enact, determine, decree and define:-] that if ever at any time it shall appear that any Bishop, even if he be acting as an Archbishop, Patriarch or Primate; or any Cardinal of the aforesaid Roman Church, or, as has already been mentioned, any legate, or even the Roman Pontiff, prior to his promotion or his elevation as Cardinal or Roman Pontiff, has deviated from the Catholic Faith or fallen into some heresy:
(i) the promotion or elevation, even if it shall have been uncontested and by the unanimous assent of all the Cardinals, shall be null, void and worthless;
(ii) it shall not be possible for it to acquire validity (nor for it to be said that it has thus acquired validity) through the acceptance of the office, of consecration, of subsequent authority, nor through possession of administration, nor through the putative enthronement of a Roman Pontiff, or Veneration, or obedience accorded to such by all, nor through the lapse of any period of time in the foregoing situation;
(iii) it shall not be held as partially legitimate in any way;
(iv) to any so promoted to be Bishops, or Archbishops, or Patriarchs, or Primates or elevated as Cardinals, or as Roman Pontiff, no authority shall have been granted, nor shall it be considered to have been so granted either in the spiritual or the temporal domain;
(v) each and all of their words, deeds, actions and enactments, howsoever made, and anything whatsoever to which these may give rise, shall be without force and shall grant no stability whatsoever nor any right to anyone;
(vi) those thus promoted or elevated shall be deprived automatically, and without need for any further declaration, of all dignity, position, honour, title, authority, office and power, without any exception in respect of those to which they may have been promoted or elevated before they deviated from the Faith, became heretics, incurred schism, or provoked or committed any or all of these.