Sometimes this is done via course pack, which is handled by the university/library/bookstore. The course packs aren't free, and the cost goes to printing the materials and also royalty payments where necessary.
Some profs may electronically distribute materials separately, which would likely sidestep both of these costs.
Yes, about 1990 one could show up at a copy shop on Rte. 1 in College Park, Maryland, mention course number and section, and get a fat stack of photocopied material. I believe that I purchased the ones I did during the last year or two such such packs were available: after that, the publishers leaned on schools to make the professors stop providing them.
I finished my undergraduate in 1998 and graduate school in 2000. Our university was still using photocopied course packets (that we purchased in the campus bookstore) that entire time.
Some profs may electronically distribute materials separately, which would likely sidestep both of these costs.