This is really weird!
I think I'm not the best person to help you, but I will try.
If you reboot LibreELEC and do this things after it will freeze too?
You use a lot of add-ons?
Try check the memory usage with top command (you also can press the m key 3 times to see the memory usage bar) before and during the library scan to see what process are using more memory.
In my experience LibreELEC freeze when it have no memory available. So, I think some process of your configuration are using a lot of memory.