Even the most local/regional colleges cost too much money in the US. Even my school, which is really affordable for a school of its size (OSU), costs around 10-15 thousand a year to attend and that's if you live there, live in the same state for years on end/are a local resident.
Sure, and a university could run less. But who would want to study there?
University is both an education and a life experience. Universities can have the academics and campus/facilities they pay for, and for a university that wants to compete for high quality students, $15,000 is probably a good deal for a good US university.
Bear in mind here in the UK the standard annual course fee is ÂŁ9,250 (~$13,000) even at low-rank institutions, and for various reasons many courses are probably running
at a loss. The USA is then more expensive than the UK generally - academic salaries are probably around 30% higher on average, for instance, again, with greater disparity likely at higher-quality institutions: because those leading research experts are expensive.
Even many local state universities in California that are funded by the state/federal/local taxpayers don't like accepting people who live there/California which is a contrast to my university, which, despite being a top 60-80 university worldwide, and a top 40 university in the US does tried to keep costs down, and will accept you if you go to a community college, and transfer; no matter what.
It might depend on how universities do their calculations. Some will be cost-neutral whether in-state or out-of-state. However, if not there is a rationale that the out-of-state get soaked for profit which provides benefit helping subsidise the educations of home students. They can also benefit the home students because the wider the talent pool, the more good students it is possible to bring in, and the pay-offs for students in peer-learning, quality, networking, etc.
Of course, if out-of-state bring in more money it may also mean that the university starts favouring them, although where universities are being subsidised for in-state students I would expect the subsidising government to include a condition for how many in-state students the university must accept.
It's a sickness in universities that they follow the same model as many companies. The fewer people that work/study here the better. They aren't even growing relative to the population of the country.
Universities, traditionally, were private institutions and many (USA) still are. It's no surprise that they might be a bit like companies.
The public university stems from a societal need to increase higher education decades ago. However, you surely have noticed the prevailing societal trend over the last 40 or so years towards the market, enterprise, capitalism, etc. as the dominant paradigm for organisations. This has affected many non-corporate organisations such as government, charities, and indeed universities.
It's not just that people increasingly think about organisations in terms of businesses. A huge amount of research and development into organisations is for corporations, and that then is applied across to other non-corporate organisations, so the principles of business creep ever more over non-business organisations; corporate consultants who take on tasks for non-corporate organisations whose ability to do those tasks themselves withers away, etc. It's also that governments expect things from universities, they spend money on universities, and so they pressure universities to get results: and they do so by using the levers that they understand, which are in large part about business. Efficiency, returns, make them compete, make them do more profit-focused work, etc.
We have turned universities into businesses. Reversing this requires a societal rethink that there is (currently) plainly no appetite for. Arguably, we are well on way to the opposite: cutting them all loose into being private institutions again.