Welcome to the community!
Since you have done a factory reset and still getting the problem it could be hardware related and would need to sent in for repair if you still have warranty.
But you can also boot the phone into safe mode and try see if its an app that is causing the freezing.
You can try following the steps here.
If nothing works then you would need to send it in for repairs.