Most of them were written by the professors who taught the course and every year or two, they'd reshuffle the contents of the book to make it harder for students to follow the course by purchasing used copies from the previous year
Most of the time only a small part of the books were actually part of the curriculum. It wasn't unusual to spend $100-$200 for a 700 page book only to later realise only 50 pages from it would actually be part of the curriculum. It seemed to me the page count had only been boosted to inflate the sticker price
I can understand why students turn to pirated copies when they realise they're just viewed as cash cows by the teaching staff