Yes, but that’s not the entire story. When talking about prestige in the field, this is indeed a large part of it. That is how you get programs that are highly prestigious in Fish and Wildlife in places like Wyoming or New Mexico - top people in the field are attracted to the location, and establish these programs in the field, and this attracts other top faculty.
This brings us to funding. Academics need funding for their research, and universities which can provide the funding will attract top faculty.
So another element is the the funding and other resources that a department can provide. So the departments who can pay the most and provide the most resources will attract the most applicants, and these will generally include the top ones.
One of the reasons that so many top engineering programs are at publics is that state and federal governments tend to be very generous with funding for engineering. DoD, DoE, and other governmental agencies have a lot of grant money for these fields. There are also historical reasons, mostly the fact that most public universities were established to provide tech and engineering education. BTW, the top private universities in Engineering, i.e., Caltech, MIT, CMU, Stanford, and Cornell (partly private), were also established to provide tech education and research.
In short, you are correct that having a strong programs attracts strong faculty, however, the ability to pay high salaries and to fund research also plays a big part, as does other reasons that make a program attractive (like location).
One of the big reasons that private “elite” universities are generally more prestigious than “elite” publics in humanities fields is that, as a rule, “elite” private universities provide more support and better pay for their humanities faculty. Not having to justify paying money for research which populist state legislators do not like or do not understand makes supporting history or gender studies a lot easier.