You're probably using an unreliable power supply. Use something official, and put any USB peripherals on a separately powered hub.
I bought a cheap USB cable tester[1] from AliExpress and ended up throwing away half my cables.
[1]: https://www.aliexpress.com/item/32973869742.html (random store, feel free to find another)
Looks like that : https://www.okdo.com/us/wp-content/uploads/sites/8/2019/06/E...