Chosen Solution

Replaced some parts in iPhone and now it powers on and stays on for different times but then it never fails to restart. WHy??

The X and above are picky when it comes to port replacements. Aftermarkets will cause them to bootloop and/or restart constantly. Source an OEM from a donor phone.