Hi everyone, I'm doing many problems in real analysis but keep forgetting many details. At the end when trying again a specific problem I solved in the past I only have the idea in my mind. Especially after learning new stuff it gets worse. I'd forget almost everything. Of course I understand everythink faster when looking at the solution. This makes me feel kinda dumb.
The unfotunate answer is that you don't want to be "remembering" proofs at all.   You want to figure them out from scratch as if you'd never seen them before.    Once you successfully figure something out on your own without relying on memory, you'll be much more likely to be able to figure it out again and again.

This is important because you will eventually forget everything (repeatedly).   It's likely that the only things you will be able to do years from now will be those things that you figured out on your own.

However, this is easier said than done.  It took mathematicians centuries to figure out all the stuff in your real analysis book.   So you can't realistically be expected to figure out everything on your own without first being shown how.

So instead, you need to employ a mixture of memory and original thinking.    It might go something like this:

1) See problem for the first time.   Try things, make no progress, let yourself be stuck for a day or so.   Read solution and make sure you understand it.

2) See problem again, after you've forgotten the solution.   Try things, make a little more progress.   Let yourself be stuck, but hopefully now you're stuck on how to get past a specific point rather than having no idea how to start.   Eventually read solution and pay specific attention to the "trick" they used to get you through the part you were stuck on.

3) See problem yet again, after you've forgotten the solution again.   Try things, maybe come up with your own solution entirely.     Or maybe you've now developed your problem solving skills to the point where you can come up with the standard solution on your own.   But, if you still get stuck read the solution and then come back and repeat step 3 once you've forgotten the details.

In short, the key is to let yourself be stuck for long periods of time and to use that time to play around with the problem.   The act of trying and failing will help you internalize the key features of the solution when you read it.
Learn the methods used to do proofs: proof of direct proof, proof by induction, proof by contradiction. Then all you need to do is remember what method you used to originally prove it and you can reproduce it at any time that you need it.