Just as a counterpoint: this very much depends. I probably spent at least a year (probably more) of my PhD (in Europe) just teaching a class I built up from the ground up myself. I barely got any research done the first year I gave that class, and every subsequent year it still took a large chunk of my time. It's part of the reason I spent a total of 7 years doing a PhD (which is long, considering I already had an MSc), during 5 of which I taught my class, and grew it from 10 students in the first year to 200 in my last. But I don't consider that time wasted. I had a blast and found that teaching helped me understand the fundamentals of my fields at an extremely deep level that I'd never reached otherwise. It didn't improve my research output, but I feel that the soft skills and understanding of fundamentals was a real advantage. My future career also didn't suffer, I'm now working as researcher at a FAANG AI lab.