Others have talked about the German system already, so I’m only going to add a few thoughts on specific aspects of the OP’s questions, namely, how long the government will keep on paying for academically substandard students.
The answer is, generally, “for a very long time.” My degree was law (which, in Germany, is a first degree - you don’t need a prior bachelor’s to be admitted, but the course takes about five years in total and ends in a degree which is considered to be at the level of a master’s, though it’s not formally styled such). Law is, in the German society, a typical degree taken up by people who want to go to university but don’t quite know what to do later on, because it offers a lot of opportunities. It is also a degree in which, traditionally, the serious testing comes rather late - the very big test is the final “state examination” at the very end; in most universities, nowadays, you do need to take a series of other exams in between, but they’re not considered particularly challenging, can be re-taken a given number of times if you fail, and don’t count towards the final grade. In addition, law is not a particularly selective degree to be admitted to; you do need the Abitur secondary school diploma to study it, but that’s not such a strong filter in an era when about half of each year’s secondary school cohort graduates with the Abitur, and most states and universities do currently not apply mandatory minimum grades that you need to have scored in your Abitur to be admitted (things are different in other disciplines, e.g. medicine, which is famously selective in very demanding minimum Abitur grades).
So it is perfectly possible for an academically sub-standard Abitur graduate to enrol in a law course, scrape by with the bare minimum for five years needed to pass a series of not-so-demanding exams for five years, and then face the big final examinations at the end and fail those. It doesn’t happen in huge numbers, but it happens in non-negligible numbers. There is no reimbursement claim brought by the government against such students or anything of the sort; they simply drop out and that’s it.
As for other disciplines, I suppose that is rarer. Medicine, as mentioned above, is much more selective in its admission, so the scenario I sketched out is less likely to happen there. The engineering and science courses have a reputation for administering much more stringent mandatory exams during the first year of the course to weed out sub-standard students in the early stages of the degree. I suppose the reason why this is not done in law (even though it is now done to a larger extent that twenty or thirty years ago, or so I hear) is that law is considered by policy-makers to be a “cheap” degree: It doesn’t require costly lab infrastructure, the curriculum consists only of lectures and seminars, and you can cram in a lot of students there (a full auditorium in a major German university can go up to a thousand students in attendance), so the per-capita costs are low.
