As others have mentioned, this broad-stroke advice is sufficiently wrong in many disciplines to be useless as general guidance. Yes, of course you need to ensure you're up to date in your subfield, but above all you need to cite whatever is needed to ground your research conceptually and empirically, whatever its datestamp might be.
With that in mind, it's worth asking: when is such guidance valid in a nontrivial way? I have encountered it most often in the humanities or in interdisciplinary work with a humanities or social sciences element. A strong caution about old references is actually warranted in fields which have undergone major paradigmatic shift, especially where the old paradigms have been criticized for being biased or rooted in privilege.
If you run around quoting "old-school", Euro-centric papers on "Primitive Art" or South Asian civilizations, especially without engaging with the paradigmatic shift in (e.g.) postcolonial theory since then, you will (rightly) get skewered. Similarly, I have read then-respected scholarship in linguistics and psychology from a few decades ago that now makes us cringe. And woe betide you if you rely blindly on psychiatric research implicitly grounded in DSM versions <=4 (6 being most recent, I believe).
That doesn't mean you can't dig up something meaningful from the historical vaults even in such fields; just that you better know what you're doing and engage deliberately with material shifts since then. Therefore a simple heuristic of "don't do it" is, in those instances, helpful.
With that in mind (and in agreement with others answering), I'd actually turn your last paragraph around. Math is pretty simple in this regard; the only issue in quoting an old paper will be the obvious one: have you failed to note a more recent substantive advance; otherwise it's fine. It's not my field, but I would expect the shifts in computer science to be more significant. While not as big a deal as in many fields in the humanities, I think your risk of coming across as anachronistically irrelevant if you're relying significantly on old references are higher in C.S. than in math.