Harvard aims to bring in about 1650 new teenagers into its campus each year to become its undergraduates. Yale aims for about 1350. Princeton sets its target at about 1250. How do elite universities determine what the undergraduate class size shall be? In the short run, dormitory and classroom sizes are a constraint. These colleges require dorm residence for at least a part of 4 years of college.
But buildings can be built and there's no shortage of money to build them. With endowments of 17.1 billion dollars (Princeton), 19.4 billion dollars (Yale), and 32 billion dollars (Harvard), the cost of construction is rather trivial. Furthermore, the construction of a major residence hall or a classroom building is always tied with a fundraising drive. And it's not like students live in dorms for free - rental price per square ft does not seem to be lower than the going market rent.
Undergraduates also pay a hefty tuition - about $40,000 per year. Top colleges love to say how they spend on each student more than twice the amount of tuition. Although not factually inaccurate, a lot of the operating cost of universities goes towards activities that do not have direct impact on student education, such as faculty research. I certainly did not feel it actually took $40,000 per year to teach me. Granted, I mostly took large lectures, for which there is just one professor supported by an army of graduate student TAs, so it could have been cheap to educate me compared to a student that loves to take seminars. But my hunch is that increasing undergraduate enrollment would not cause the school to lose money, as long as expenditures such as research do not go up with enrollment (there's no reason why a school should do more research because it has more undergraduates).
How does Harvard, Yale, and Princeton come up with their magical numbers of undergraduate class sizes, then, if money is not really the issue?
It is said that Harvard receives 300 applications a year from people whose academics are so superior that they could be admitted based on academics alone. Then there are people who are not academic superstars but still are very good students combined with great extracurricular activities (leadership, in particular). There are development kids, whose families have donated large sums of money. There are legacies. There are athletes. There are black, hispanic, or American Indian kids, who are admitted even if they are not in the aforementioned categories because they bring "diversity."
The number of students in each of these categories are limited, because even the students in favored groups - development kids, legacies, athletes, and "diversity" - must still meet a relatively high level of academic and/or extracurricular excellence. Alas, Harvard sets its number at 1650 because that's approximately the number of students that it deems worthy that Harvard can entice to attend. For Yale and Princeton, its somewhat lower, probably because Harvard has a bigger name and has a slight upper hand in attracting cross admits. Top colleges set their enrollment numbers with the specific intent of making admissions very selective, so that they can remain elite and prestigious.
Many people gripe about how unfair it is that rich kids, legacies, athletes, and "diversity" students are selected over more accomplished applicants. It is not the intention of this post to comment on the fairness of college admissions or whether this type of favoritism is actually good for the students, the school, or society. My point is that the total number of elite college slots have been determined under the assumption that some slots will be reserved for these favored groups. In the short run, it is true that the admission of one less accomplished favored group student results in the rejection of a more accomplished applicant. But in the long run, the number of slots is fluid. Elite colleges determine how many of each year's crop of 18 year olds are elite enough, and then will set enrollment at that number.