Hello!
This appears to be a hardware problem. I recommend you contact Apple Support for service.
Only go to Apple, an Apple Authorized Service Provider, or send your device to Apple for service (if applicable or available). Do not go to a 3rd party/unauthorized repair center or attempt a repair yourself. This is for the assurance of authorized and professional repairs that use genuine Apple parts. Please refer to this from Apple Support:
Beware of counterfeit parts
Some counterfeit and third party power adapters and batteries may not be designed properly and could result in safety issues. To ensure you receive a genuine Apple battery during a battery replacement, we recommend visiting an Apple Store or Apple Authorized Service Provider. If you need a replacement adapter to charge your Apple device, we recommend getting an Apple power adapter. Also non-genuine replacement displays may have compromised visual quality and may fail to work correctly. Apple-certified screen repairs are performed by trusted experts who use genuine Apple parts.
Jack