There is a scientific reason for this. Prepare for minor text wall.
When you fall asleep, your brain erases temporary memory and “closes” permanent memory so that nothing can be stored to it during sleep. This is also the reason you can’t remember what you did a few minutes before falling asleep. Therefore, your dreams are stored in temp memory and you can only remember them for a little bit after waking.
Don’t quote me on this, I found it somewhere, and my somewheres tend to be pretty reliable, but I’m too lazy to fact-check. Feel free to downvote if wrong.
Fun fact! You can train your brain to remember dreams by keeping a dream journal. When you brain dump your short term memory upon waking up your brain starts thinking dreams are important and you can have more vivid and lucid dreams.
Can confirm. I kept one for a year and the memories gradually got stronger. I was surprised to realize that I was usually having 2 to 5 different dreams each night.