Unfortunately, older RAM also means an older motherboard, which also means older socket and older CPUs. It works, but it's not usually a drop in replacement.
Well, they're entirely different, not just slot. Intel 12th/13th/14th gens all support DDR4 or DDR5. However, the motherboards you buy can only support one or the other. I don't think there are a single AMD CPU that supports both?