They simply messed up. All they had to do was say nothing and reach out to the manufacturers making N95 masks and their retailers. Just going to Walmart and Amazon and getting them to pull their stock would have prevented the vast majority of people from getting their hands on them. A non-trivial number of Americans at the time had already been wrongly and loudly bleating about how masks were useless and were really about "controlling the population".
The CDC lying to the public was plain wrong. However well-intentioned, it was a terrible shortsighted error in judgement that cost them all credibility. The CDC is perhaps the one agency we most need people to trust and they proved themselves to be untrustworthy.