Welcome to Android Central forums.
What device do you have?
Is it all games or specific ones?
Do you have an ad blocker running or antivirus, malware or data saver app running?
With one of the affected games open, in the background like you just switch away from it without closing it, are you able to get a connection? You could test this by opening YouTube and playing it in the mini player while also trying to open and play one of the affected games.
I should have asked this before the last question perhaps but when you say it disconnects do you have to turn it back on or just close/leave the game?
Does the same happen with mobile data? You only mention WiFi but do not mention just using carrier data.
Depending your device you can remove access to the internet for certain apps of your choosing in the connections settings. Have you looked at them or any other settings to see if these apps are restricted? This would include the permission settings for these affected apps.
Did they ever work or have they never worked? If they used to work did something happen around the last time you remember them working? An update, the installation of a new app, some change in service?
Have you tried resetting your router? Usually this is done by unplugging it for 30 seconds to 1 minute and then allowing it boot up.
Have you tried restarting your device? Not resetting it, just powering it down and back up again.
I'm not sure we have enough info to really offer advice but if you can answer these questions it would move us in the right direction.