Once you understand something, you could use it in new situations.

You asked how to not forget it. This is a separate problem and I wouldn't blame it on "lack of understanding" if you forget things.

Even for university level mathematics, it's not sufficient to just understand, you also need to remember.

In some of our math courses professors allow a cheat sheet of theorems and formulae during exams because remembering things is tough and they want to evaluate students on understanding

Practicing problems is a very common way in math to both understand and remember. It helps you understand because it pokes holes in your understanding when you think you've understood but actually haven't. And if you've freshly done some problems involving a theorem, formula or a technique then it'll take time to wear off from your memory.