The phrase suggests a negative change due to stress or trouble, affecting someone's appearance or mental state. After the trial, the defendant looked as if the experience had put years on him.
Pro Tip 2/3
Not Literal
It doesn't mean actual aging but a perceived increase in age because of life events. Seeing her son ill, she felt it put years on her overnight.
Pro Tip 3/3
Hyperbole
Often an exaggeration, not to be taken as a precise measurement of age. Running my own business has put years on me, I swear I look older!