Idiomatic... not sure, but it's a common enough construction that native speakers know it well. They had anywhere from a few minutes to a few hours...
They are carrying anywhere from a few quarts to a few gallons...
We do anywhere from a few dozen to a few hundred drills every day...
The sentence sounds idiomatic to me. "Ago" only appears once, but the sentence means that these people graduated anywhere from a few years ago to a few decades ago. In other words, some of the people graduated a few years ago, some graduated a few decades ago and some graduated less recently than the first group but not as long ago as the second group.
It seems strange to me to hear ...where used with time periods.
If I replace all of those with the equivalent ... thing words, the sentences are generally OK.
They graduated anything from a few years to a few decades ago.
They graduated anythingbetween a few years toand a few decades ago.
They graduated something between a few years toand a few decades ago.
The second sentence feels a bit odd, but I've no idea why.
Could it possible that "somewhere between X and Y" means only one point of time between X and Y, while "anywhere between X and Y" means many different points of time between X and Y? I don't know if I think of this in the right direction. If so, since the subject is "they" but not a single person, would it be appropriate to use anywhere, not somewhere?