Check the FAQ.
You will find some good information there, but too much to repeat it here.
In german it is called "rostfrei" a bad but direct translation would be "stainfree".
The english word shows it better: It stains less.
The key is in general an addition of 12 - 14 % of Chromium in the steel.
But the chromium has to be solved (can i say that?) in the steel. By heat treatment chromium can form carbides, which help to get the steel wear resistant, but this "bounded" chromium has no influence on rust anymore. 440C is an example. A part of the chromium helps to get it stainless and another part of it is used to get it wear resistant.
Steels like 154CM or S30V just have the minimum of chromium to get it stainless, 14%. By heat treating elements like molybdenum (154CM = 4%; S30V = 2%) and vanadium (154CM = 0%; S30V = 4%) are more agressive carbide formers and these carbides are harder than those from chromium, so the chromium remains in the steel. In that type of steel chromium is mainly added for stainresistance.
By heat hardening and tempering it may happen, that a part of the chromium forms carbides too. That is another possibility, why some "stainless" may rust easier than others. But that is a particular thing, not a general thing of the steel grade.