Why do we forgot things...
Have you done an online transaction today? You received an OTP on your phone. You read it,(memorized it) and entered those digits in the specified box to authenticate the transaction. The transaction was successful!
Do you remember that OTP now. In fact, as soon as you entered that OTP, you forgot it.
On the other hand, you never forget your ATM Pin! It is always ready to be recollected. Even if you don't use it for months.
Why did you forget your OTP but not your ATM Pin? Because you knew that once it is used, the OTP will no more be required and that you would require your ATM Pin for ever. Accordingly, you instructed your brain to retain the OTP just for a few seconds but to retain the ATM Pin for ever.
In the same way, when you prepared for the exam, which was scheduled for the next day, you instructed your brain to retain the content of your study till that exam. Had you studied with the intention to learn the content for expanding your sphere of knowledge, you brain would have received instructions accordingly and the content would have been retained it in your memory for ever!