How do so many people here on Academia.SE, and in general, afford lavish higher education programs?
Bachelor and Master degrees are a lot cheaper in Germany. In fact, they are mostly free (you need to organize and pay for your housing and living). For a PhD you don't pay but get paid, often with employee status, but sometimes with a stipend instead. So financial issue pose significantly less of a constraint compared to the USA.
In many places, including the US, study for the doctorate, though perhaps not so much for the Master's. comes with some sort of funding. The funding is often dependent on work, either in a lab or as a TA (the most common case). In popular fields, such as math and CS, doctoral granting institutions also normally teach a lot of undergraduates. It is normally much more than what the full-time faculty can handle. I studied math long ago and there were two funded doctoral students for every faculty member. About 70 faculty and 140 TAs. We made dirt scratching wages, but it was enough, but only because our housing was also subsidized. I finished with a small family and a doctorate. My spouse was also a student in a different field with little funding.
But doctoral study isn't just tuition driven as undergraduate study is in much of the US.
Being a full time employee somewhere and also a full time doctoral candidate, however, is very difficult. If you have substantial financial obligations it is even more difficult unless you can find a part-time program (which exist).
However, if you can live on poverty level income for a while, you can earn a doctorate without substantial debt. It isn't the fastest way to a degree, of course, since you are a part-time employee, but it can be a good trade off. Note also that tuition isn't normally charged to TAs. However, US tax law is gettin weird. Some want to treat the tuition "grant" as taxable income, which becomes impossible to cover, given the low pay. Stupid. Stupid. Stupid. It is as if some people want a stupid citizenry. I'm not certain of the current state of that proposal.
If you intend to be a teaching scholar (as in the US) then a TA position will help you learn the art of teaching (by osmosis, mostly), so it contributes to the overall goal. But if you intend to be a research scholar, look for a funded lab that will get you deeper into the research a bit earlier.
I don't have personal experience in Europe, but from colleagues, I get the idea that doctoral students are more or less regular employees that do most of the things that regular faculty do, up to and including advising of other doctoral students. One friend successfully advised a doctorate for another student, but left without his own. These sorts of things seem to occur both in UK and in Germany, at least, but others there can give a more complete picture. The positions have a lot of responsibility, but you are low ranked and only adequately paid. But enough to raise a family at least, if that is an issue. Such positions of responsibility are uncommon in the US.
Caveat. My experience and the above is from Mathematics, computer science and some of the other "hard" sciences (what ever that means). It differs in other fields. See other answers here for very different situations: say indigochild. Someone has to be willing to pay for the support, government, foundations, industry, etc. Or the candidate as the last resort.
There is a kind of survivorship bias here. Many graduate students do not have access to funding or significant personal wealth, and are not able to complete PhDs at all - let alone very expensive ones. If you ask people who did complete PhDs about their financial resources or education costs you will over-estimate both, because the graduate students who complete PhDs are likely to have had more resources than those who did not.
In my cohort (a social science program at an R1 in the U.S.) there were perhaps 30 students accepted, of which only a handful had financial support (they were paid teaching assistants, which came with some tuition remission). Of course, once we completed our M.A.s most did not progress to PhD work. We took jobs outside of academia. Certainly our economic or financial situations were a large part of this.
Contrary to Buffy's answer, in my cohort financial hardship was common. Tuition and fees for out-of-state students for us was about $30,000 per year. Even living inexpensively at that point means that you would need a good full-time entry level salary (in our area) to cover your basic expenses.
On the other hand, the few students with departmental support continued on to complete doctoral programs. Some others with significant personal wealth were able to complete Ph.D. work also, but at least among the people in my cohort, that was only a clear factor for perhaps 1-2 people. Debt for unfunded graduate students is almost a foregone conclusion.