If you want to learn from a book, you have to play a more active role. Personally I find that the process of learning from a book involves A. read it once, straight through like a novel - maybe underlining key passages in pencil, then B. reading again and taking detailed notes as you read, and possibly looking up citations, or related references (the Wikipedia page for a particular term or phrase, for example), then C. re-reading your notes a couple of times as well as reading and re-reading supplemental material that you found, and finally D. writing your own synthesis of the material.
Yes, that's a lot of work and yes it takes a long time and no, not every book justifies doing all that. Sometimes it's OK to just read the book like a novel, and walk away with just a vague memory of the highest level themes and maybe detailed recall or one or two specific points that resonated with you. It all depends on why you're reading the book and what you hope to get out of it.
Edit: and if it's a book with exercises, then add "do the exercises" as another step. That said, I see reading / working through a textbook to really "learn a subject" as being a slightly different thing from reading the typical pop-sci book or business book or whatever, that doesn't generally have exercises. "Learning a subject" to me usually involves using multiple books, videos, articles, maybe writing some code, etc.