I feel the same happens to me from time to time. Everyone is different but for me it was that I zoomed by the course quick, fast, and in a hurry thinking that I mastered it at the time because I recently learned the topic but then I came back to it later had no clue about what to.
My personal solution and what I read a good amount of programmers have written is time and repetition knowing that if you think about the code and practice the code consistantly over time you are going to get it and its going to stick.