Mixture of things:
1. In many states, the community-college system is still heavily subsidized, while the flagship schools have been moving towards a "user-pays" model. For example, the state of California has cut its per-student subsidy to the University of California system by about 60% in real terms over the past 30 years, but has cut their per-student subsidy to the community-college system by only about 20%.
2. Community colleges typically are looser in who they'll hire to teach classes: no PhD required, can teach part-time, no research expectations, etc. Like with any field, if you have lower requirements, you can get staff for lower salaries, e.g. hiring C++ programmers vs. web designers.
3. Prestigious universities have suffered more administrative bloat, I guess because it's where the prestige is, so attracts empire-builders. Community colleges don't pay their President $500k/yr, or have an army of Assistant Vice Chancellors.
4. To be a "top school" there are higher expectations of the other resources provided besides the actual classes. A community college typically has a small or no library, while UC Berkeley is expected to have a full-coverage research library. UC Berkeley is also expected to provide good laboratory and computing facilities, dorms, security and healthcare for an on-campus resident population, etc.