My phone will automatically open camera and take a selfie even without touching the screen,
This is happening on my Samsung a50
Put the phone into Safe mode and see if it happens while in Safe mode. If it doesn't happen there, then a 3rd party app is probably to blame.
To get into Safe mode: