I found this an additional context:
Scratch files and buffers are temporary files but they will persist when you restart IntelliJ IDEA even if you invalidate your caches. However, they will be removed if you restore your default settings or reinstall IntelliJ IDEA.
https://blog.jetbrains.com/idea/2020/11/scratch-files-and-scratch-buffers/
Hope this helps.