Of course it matters, holding everything else constant. But sometimes is the other way around; prestigious departments attract the best people (hard working, ambitious; I don't necessarily mean that they are the smartest) and so they tend to publish more papers. I've worked with well-known professors at top departments and their papers get rejected left and right, but they have many projects, funding, etc. As a student, it depends on you and how you make the most of out the opportunities. Yes, big names have more resources, networking, knowledge and so on, but it's you who will have to do a lot of work and produce quality research. They won't do it for you. All the famous profs I know are non-stop working machines. Sure, they are pretty smart, but they got where they are by working very hard.
In summary, it doesn't hurt to go to a super prestigious school but getting into one is not going to guarantee anything for you.