You can try these steps to cool your phone
Settings > Select Device Maintenance/Device Care > Optimize > Optimize all options like Battery, Storage and Memory
If u find this helpful kindly click on the three dots and click accept as solution
Dear Samsung Member,
Greetings from Samsung Customer Support!
Please visit this mentioned link to resolve your device heating issue: https://www.samsung.com/in/support/mobile-devices/why-the-device-heats-up-during-use/
For further assistance, register your concern in Samsung Members Application (Open Samsung Members Application > Get help > Send Feedback > Error report/Ask questions).
Thank you for writing to Samsung.
Samsung Customer Support