University departments do not always have the kind of autonomy your post implies. It is common for the university’s central administration to dictate how many students they must let it, how much money they get per student, and hence how many they can fail without going into the red.
None of this has to be for-profit. It just requires the university administration to put its wants, priorities, and head count (!) above the interests of the individual departments and of the students.
Making the whole thing a non-profit or a charity won’t solve this.