From whom do prospective grad students get recommendation letters? Most top graduate programs require at least 3 recommendation letters. Do students who apply to such programs (and have a reasonable chance to get in) typically have such extensive research experience that they know three professors who can write in detail about their research? Or is it more common for such students to have some recommendation letters from faculty who can confirm that the applicant is competent (for example because they did very well in their class, won an award, ...) but with whom they have not worked much personally?

I understand it would be ideal to get all letters from faculty with whom you have worked closely on a research problem. But I wonder how commonly this actually happens, especially considering the fact that the final undergraduate year typically cannot be taken into account for applications in fall.

If it depends much on the discipline, I'm in physics.
In general, I don't think all that many students have three unique reference letters, all of whom can vouch for research ability. Two is quite common, as most undergraduates who pursue graduate degrees (at least in the sciences) do have some research experience at their home universities. Many of them also pursue a summer research project separate from their main undergraduate research project (or projects), providing another reference.

But I do agree that the third letter usually comes from a non-research source. I wouldn't even necessarily expect a third research letter.