The IBM PC and its successors the XT and AT used a 5-pin din connector for the keyboard. On the XT and AT this was the only external connector placed directly on the motherboard (the original PC also had a cassette connector), other connectors were on add-in cards.
IBM's next system the PS/2 introduced in 1987 brought us the mini din keyboard and mouse ports but unlike previous IBM systems, the PS/2 was not widely cloned. Many PC clones continued to use derivatives of the AT form factor and hence continued to use the AT keyboard connector. Other PC clones used vendor-specific form factors and some of these did adopt the PS/2 keyboard connector. The PS/2 connector also became the norm on laptops with many supporting a splitter to allow a single connector to support both a keyboard and a mouse.
Systems using the AT form factor varied in how they handled the mouse. Some did not have a PS/2 mouse socket at all, requiring the user to use a serial mouse. Some had a PS/2 mouse port on a flylead to an expansion slot backplate or a mounting hole on the case. Some apparently used a variant of the form factor with a PS/2 mouse port on the motherboard though I have never seen this personally.
In 1995 intel introduced the ATX standard. This replaced the dedicated location for a keyboard connector with a flexible IO panel. For the first decade or so of ATX's life*, this IO panel nearly always incorporated a double-stacked mini din connector for the keyboard and mouse.
Intel pushed ATX heavily with the Pentium 2 and nearly all Pentium 2 systems used ATX, hence the PS/2 keyboard connector. Systems using AMD and Cyrix processors hung on for longer but ultimately the death of socket 7 around 2000 was also pretty much the death of the AT/Baby AT form factors and the 5-pin keyboard connector.
The AT and PS/2 keyboard interfaces were electically the same, only the connector was different. During the period that both standards were in use, adapters were readilly available and when I do a quick google for "ps/2 At keyboard adapter" it seems they are still available today.
* Eventually as USB became dominent, many motherboards dropped the PS/2 connectors or replaced them with a single combined keyboard and mouse connector, but that came much later.