I'm sure you're right about those book mixing up the names; I've not read them myself in ages so I can't comment.Somehow the two characters have been conflated, probably at the source. As noted in the entry for "Sam", James Blish called him Sam Ellis, as that was the name given the character in the early draft script Blish used for reference. By the time the episode was referenced in background materials like "The Making of Star Trek" by Stephen Whitfield and "The World of Star Trek" by David Gerrold, they were using call sheets and the like to attempt to fill in the gaps. When they found the name Tom Nellis, they assumed it was Sam renamed; indeed, one of those books actually stated that to be the case (I don't remember which one). If I'm wrong, and I'll admit it if I am, that earlier error by others is responsible, as I'm just using that information as my source.
The character of "Sam" in Charlie X wasn't even given a surname in the episode; an oddity in TOS where people rarely referred to each other by their first names