For RPGs they almost always outsource the writing. Crafting a good story is not really a skill that a lot of the major developers have a lot of call for (normally they just have you shoot the bad guys because) so they don’t have people on staff for it. In RPGs stories are a lot more important though, so they actually have to put some effort in.
Aren’t most RPG video games developed by companies that primarily do RPG video games? Like, Warhorse was founded specifically to make KCD. Fallout Shelter is the only non-RPG Bethesda has developed since 2008. And The Witcher Adventure Game and the Gwent games are the only non-RPGs CD Projekt Red have ever done.