Here's a source explaining:
ELEMENTS OF ECCLESIASTICAL LAW, REV. S. B. SMITH, D.D., 1887
Vol. 1. ECCLESIASTICAL PERSONS, PP. 149-151
339. Q.-I. By whom and how were bishops appointed at various times?
A. The history of appointments to episcopal sees may be divided chiefly into three periods. 1. First period.-Christ himself first chose his apostles. The apostles in turn appointed their successors, the bishops. The clergy and people not infrequently took part in the appointment of bishops, as made by the apostles. Afterwards, appointments to bishoprics were, as a rule, made conjointly by the metropolitan, the bishops of the province, the clergy, and the people of the vacant diocese The elections seem to have been held usually in provincial synods. According to some canonists, the people merely gave testimony of the character of the candidate; according to others, they actually exercised the elective franchise. It is certain that the laity are not jure divino possessed of the right of electing bishops. In some instances, especially where it was feared that these elections might give rise to dissensions, the metropolitan sent some bishop episcopus visitator to superintend the election.
340. Bouix thus describes the mode of election of this period: First, the suffrage of the people or laity was necessary; second, that of the clergy of the vacant diocese was also required; third, the consent of the bishops of the province was, moreover, indispensable to the valid election of a bishop.
341. Bishops, however, were not unfrequently appointed even during this epoch, directly by the Holy See; especially is this true in regard to the West, where for the first four centuries bishops were directly and solely appointed by the Holy See.
342. II. Second period.-In the twelfth century the right of electing bishops became vested solely and exclusively in cathedral chapters.
343. III. Third period.-Owing to abuses consequent on elections by chapters, the Sovereign Pontiffs began, in the fourteenth century, to reserve to themselves the appointment of bishops. Clement V took the first step in this matter, by reserving the appointment to some bishoprics; John XXII. increased the number, and Pope Benedict XII (1334) finally reserved to the Holy See the appointment (i.e., the election and confirmation) of all the bishops of the Catholic world. Elections by chapters were consequently discontinued everywhere. Afterwards, however, the right of election was restored to cathedral chapters in some parts of Germany, so that in these parts only bishops and archbishops are still, as of old, canonically elected by their cathedral chapters.
344. Q. Were the Roman Pontiffs guilty of usurpation in reserving to themselves the appointment of bishops?
A. By no means; for the Pope alone is, by virtue of his primacy, vested with potestas ordinaria, not only to confirm, but also to elect bishops. Hence it was only by the consent, express or tacit, of the Popes that others ever did or could validly elect bishops.