I hate to admit this, but I'd always just assumed they kept their membership secret because it was an illegal organization. But I guess... it never was actually illegal to form and have a CP in the US... was it?
The underground party kept separate from the open party, using it as a source both of ignorant tools and recruits. Its activities were mostly illegal (which is why it was underground), things such as fraud, espionage, and even the occasional Arkancide. In such a case, everybody in the organization, if not open to the direct criminal charge, is on the hook for conspiracy to commit same.
And, although I say the open party was legal, its members were mostly aware of the underground, even if they didn't know who was in it, and they supported its general mission even though they had plausible deniability of its misdeeds.
If you've never read Witness, check it out. Whittaker Chambers tells his own story of the CPUSA, both open and underground, from an insider's viewpoint. (And let me add to that, his mastery of English makes him a pleasure to read, on the level of Tolkien or even Milton.) Then check out the biographies by Tanenhaus and Weinstein. (I liked Weinstein's better. )