How do textbook authors and professors cook up homework/assignment questions?
You missed scenario f, which I suspect is the most common:  The professor has been teaching this class and refining the textbook/notes for years, and developed homework questions out of problems that have come up over the course of that extended period of time of engaging with this material.