As a grad student in computer engineering, I have a similar problem when I switch between projects that use different programming languages. I might spend months working in a high-level language like Python, only to switch to a project using a low-level language like C, or a project whose language I'm unfamiliar with, like MATLAB.
As I see it, there are two issues here:
1. Documentation -- setting a project aside is unavoidable at some point. As @Bemte pointed out, the trick is to document your work well enough where you can pick the train of thought back up days, weeks, or months later. This takes time and effort to do well (something I'm still learning). Suffice to say -- your documentation should include everything that you need to familiar with the work in a reasonable amount of time. That might include:
- Detailed notes of the conversations you had, proofs you were working on, etc.
- Papers you were reading
- Textbook chapters that are important
- And so on.
2. Patience -- you said it's been a couple of months since you had looked at your work. I can say for sure that if I went 2 or 3 months without looking at my code, it would be like reading gibberish, and it would take me a couple of weeks minimum to get back up to full productivity. I may be reading too far into your words, but it sounds to me that you need to be patient with yourself. High-level mathematics is not a subject that you learn overnight; and any psychologist will tell you that it takes time to enter the flow. Be patient with yourself.
I'll add this quick caveat: if you're concerned that you're still forgetting information even after you've been working on it continuously for weeks/months, that may be a sign of a more significant neurological or mental health problem. In that case, consult with (medical) experts. (Update: see @aparente001's excellent answer on how to best do this here.)
But otherwise, it's likely just a matter of being human -- we all forget things after a while :)