Epic Games does way more than just purely making games.
They also have their own Steam competitor (Epic Games Store) and, more importantly, they develop and support Unreal Engine used by tons of other game dev companies.
If you want an apples to apples comparison (i.e., other big live-service game companies) in terms of the employee count, you got:
Mihoyo (Genshin Impact, Honkai Star Rail) - ~5,000-6,000
Riot Games (League of Legends, Valorant) - 4,500
Roblox - 3,500
Epic games store is likely a main culprit as they really have not succeeded while spending tons for free games
Mihoyo literally prints money with predatory gacha
Riot has had several layoffs in recent years
Roblox loses tons of money every year
The game store doesn't need a lot of employees. A few years ago it was reported that Valve only needed about 70 employees to run Steam while it generated billions of dollars in Steam fees (30% per game). It's basically free money for Valve. I bet the situation is similar for the AppStore and Google Play.
Though Unreal Engine does indeed need quite a few developers. Additionally, using UE is much cheaper (5% on games exceeding 1 milion USD gross revenue) than using Steam (30% on every game). So they not only need more developers than Valve, they also earn less money.
What about Valve itself? They have ~350 employees. They make Steam, SteamOS, Steam Deck, Steam Machine, Steam Frame, the Source engine, and run four actively successful live service games: CS2, Dota2, TF2, Deadlock.