There's no right or wrong way to do this. But, the reason we say CPU then RAM is because:
Sometimes, at your given core OC, you wont even be able to reach your rated XMP settings on the RAM. However, the core OC will greatly effect performance across a multitude of programs and applications. moving the memory from standard DDR3 or DDR4 settings usually yields much less.
Now if you had OC your memory first, you may get unstable and think you have reached your maximum OC on the core, when i reality you could have went farther. In this case you would have your memory OC and a mild CPU OC. The problem with this scenario is that in most games and applications, lowering the memory and boosting the core will yield more performance
There are a lot of other complicated OC techniques that take into account memory speed, buss speed, core frequency and multipliers all working together to get the most out of the chip, but most people are dealing with core and memory, and in that situation, "core is king"