Lets talk about some statistics first-
- institutional prestige matters in hiring decisions made by committees. Getting your PhD or doing a Postdoc at a top 10 university matters. The degree in which it matters varies across fields. If you did not get your PhD in History from Harvard, you are at a major statistical disadvantage in obtaining a tenure track position. See Clauset, A., Arbesman, S., & Larremore, D. B. (2015).
- Publishing during your PhD career is highly correlated to your academic productivity during tenure track. Graduate students tend to have better publications records at elite institutes. See Horta & Santos (2016). Whether this is because of the more competitive culture, the increase in graduate student "quality", or the pressure from a demanding professor is unknown. Probably a combination.
- These above two factors depend on field. Fields that have strong cultures of scholars having been in the field prior to academia give less weight to institutional prestige (e.g. education and nursing) but they still care.
So in other words, grad students in an elite university tend to publish more. They also tend to dominate tenure track positions.
You dont have to go to an elite university for your phd, but you at least need to do so for your post doc or masters.
In my own experience, I had a strong publication record at graduation, did my postdoc at an elite university, and was hired for a tenure track position at an R1 university. My advice might very well be biased to my own experiences but I feel that the data and statistics say that my experience was the norm rather than the exception.