I have a friend who was a medical entomologist and journal editor before he retired. I ran into him while I was browsing a book table at a conference, and mentioned that I'd like to buy one of the medical entomology textbooks but the $250 price tag was a bit steep.
"Just wait," he said. "I'm about to change that. I'm writing a new textbook that will be a lot cheaper. I want students and public health departments to be able to afford a solid medical entomology reference."
When his book came out the publisher set the priced at $500. It was twice as expensive any of its competitors. Now something like this is never going to sell like a basic calculus book, but it has a considerably larger market than you'd think. His idea was that it would find its way into the syllabus in medical, veterinary and public health schools; and that hospitals and public health agencies would buy copies for their libraries. But his strategy to make that happen by making the book affordable and sell in (relatively) high numbers; the publisher had other plans.
So don't blame authors for high textbook prices. It's publishers who set the price.