Don't use it while charging.
Don't keep it in warm places ( like under the pillow or any other heated area)
If you feel it's getting unnecessary heating issues then visit service center.
Bro many people say they have buzzing headphone problem in M31s. I wanna buy it, could you pls check this for me?
Discharge your battery to 50%, put on 3.5 mm earphones, play soft music on youtube & only after that plug in the 25 watt charger. See if any buzzing noise comes.
Also mention in which country was your phone made & which year.
If it heats a lot, make sure you have installed the latest update
Clear cache partition in recovery mode