Chosen Solution
My phone switched off automatically during charging or whenever it’s temperature increases it’s getting switched off. Even when it’s not in charging mode it gets switched off while heat up.
Because it is overheating. Are you using the stock charger?