It is NOT supposed to get VERY warm while recharging or playing.
It may be an issue with the battery or with the mainboard. iPhone 4 is almost 6 years old and it is possible the issue is related to battery.
To make sure this is not something else, like a software glitch we can do some troubleshooting steps. Go to Settings > General > Software Updates and do all software updates available. Then go to Settings >General > Background App Refresh and turn it off.
Then double click on the home button (round button at front bottom) and this will bring multi tasker. Swipe up on the apps and close all opened apps.
Once you did that, reset your iPhone. To reset, press and hold down the Power button and Home button at the same time until it shows the Apple logo. When you see the Apple logo, release the buttons and let it boot.
This will soft reset it. If it still getting hot, then we can try to restore a fresh software from your computer. It might not help, but we can try. This is generally occurs if there is any issue with the hardware components.
Let me know how it goes please.