"Hacked" is probably the least likely explanation (it's a conclusion people often jump to when they see something they don't understand, but usually there's a more prosaic explanation).
I don't know about the S9 specifically, but we have over the years had occasional reports of spontaneous factory reset from a number of different members. Sometimes it follows some event like the phone running out of power and turning off, but not always. So it's very unusual but it's not actually unheard of.
Unfortunately when the only symptom is that the phone is wiped it's very hard to identify the cause. It could be a glitch during a system update, especially if you have one of those phones where the carrier can push the update without requiring your consent, since then it could happen without your knowledge. Or it could be the result of some hardware glitch or fault. But we've really nothing to go on to identify the cause.
If you want to persue the "hacker" line, check your Google account (and Samsung account if you have one) for any unrecognised activity, such as logins from devices you don't know (logins from places you haven't been to are harder to judge, since they get that from my internet provider or network operator's IP address rather than the actual location of my phone or laptop, so logins on my Google account often appear to be from my device in a place I've never been). If you see unrecognised logins you should secure your accounts anyway, and deny access to those devices. The reason I'm saying to check this is that your accounts are the most likely way into your phone. But I think it very unlikely that this is the cause.