Replace your battery.
Your phone is 2 years old.
Phone batteries are typically designed to last around 2 years before they really degrade because a lot of people buy new ones around every 2-3 years.
When the battery can't sustain the same throughput, the phone can handle this in one of two ways.
-
Slow the phone down. This is what Apple does and why people with iPhones 2 years old complain the new update slowed their phone down.
-
Don't slow it down but if the throughput drops below what's needed, die and reboot. This is what your phone is doing.
Getting a new battery will probably stop this behavior (and for iPhone users reading this, getting a new battery for a 2 year old phone will make your phone faster).
Edit: Seems some of you don't believe me looking at the downvotes. Look at number 8 in this list: https://helpdeskgeek.com/help-desk/why-your-android-phone-keeps-restarting-and-9-ways-to-fix/