"D sub" connectors are not specific to a given protocol. The same connector was, and is used for multiple incompatible applications.
Male connectors are slightly more damage prone than female ones. This was, and is, sometimes seen as a good reason to put male connectors on (relatively cheap) cables and female connectors on (relatively expensive) equipment, but this was far from universal.
RS-232 historically used a 25 pin male D connector for "Data terminal equipment" (computers and terminals) and a 25 way female D connector on "Data communications equipment" (modems).
The original IBM PC made heavy use of D sub connectors for multiple applications. Presumably because they were one of the few types of connector that would fit on it's expansion slot back plates. A male 25 way D connector was used for serial ports, a female 25 way D connector was used for the parallel printer port, a female 15 way connector was used for the game port, and a female 9 way connector was used for the monitor port. A 37 way female connector was provided on the floppy controller for external floppy drives, though I don't think this was widely used.
When IBM released the PC/AT they introduced a parallel/serial combination card. This used a 9 pin male connector for the serial port, presumably they used a 9 pin connector because there was insufficient room for two 25 pin connectors on the same card. The choice of male, also seems logical given that it was both consistent with the prior use of 25 pin connectors, and avoided ambiguity with the video output.
Later the 9 pin video output connector was replaced with a 15 way high density connector as part of the transition from CGA/EGA/MDA to VGA/XGA.
Both the 9 and 25 pin serial connectors remained common on PC clones for many years after that. Afaict the 25 pin serial connector finally started to disappeared from most PCs with the move to ATX in the late 1990s. Early ATX motherboards typically had two 9 pin serial ports on the motherboard with a 25 pin parallel port above them. Motherboard with on-board graphics would often replace the second serial port with a VGA video output port.
In 1999 microsoft introduced the PC99 specification, which brought in the colour code for the ports seen on your motherboard.