Yes AM4 and AM5 are socket from AMD (by Intel the sockets are called LGA and then a number).
The socket together with the installed BIOS Version specifies the CPUs which can be installed on the mainboard.
Indirectly the CPU has a influence to the graphic card, too because a very weak CPU can slow down a graphic card.
And graphic cards communicate over PCIe with the CPU. The current version of PCIe is 5.0 and which PCIe version the card can get at best is specified from CPU, too.
For example if the graphic card supports PCIe 5.0 and the CPU offers PCIe 4.0 at best the graphic card falls back to PCIe 4.0.