It sounds like your problem has more to do with retrieval. You _learn_ something when you retrieve something from your working memory or long-term memory (you build myelin, a fatty substance that isolates your synapses, which enables you to later retrieve the information).
The optimal way to learn is to use spaced repetition. It naturally happens if you apply the knowledge frequently, or you can use a flashcard app to track it.
If you struggle to _understand_ something, it often has to do with overwhelming your working memory. You are connecting several concepts that you don't understand. On average, most can keep seven items in their working memory, but after that, you'll start feeling lost.
When you internalize a few concepts by retrieving them, followed by a long break or sleep, you free your working memory to connect more concepts.
[1] https://www.inc.com/scott-mautz/train-your-brain-to-remember...
At the moment I’m working through CLRS intro to algorithms. There’s some math in there and derivations. I tend to run through the derivations separately while I’m working through the content to really internalise them (and I just enjoy the math). The author is nice enough to provide extensive problems to solve too.
Similar can be said of The Art of Programming. Plenty of maths in there to follow along with and plenty of problems to solve.
In addition, don’t be afraid of revisiting content. If you read over a text once but don’t fully internalise it, you hopefully have gained enough knowledge to have an idea of when it might be useful to you. So when you’re working, go back to the text and read through what’s useful and implement that.
I've lost count of the number of times I've read a chapter in a book, felt I understood the material very well, but utterly and completely failed to reproduce anything when you take the book away and replace it with a blank piece of paper (or IDE).
Usually you can tell that you've failed to internalize everything when you try to teach it to someone else. You become aware pretty quickly where the gaps are. If you're on your own, though, it requires a lot more discipline.