Because they were working on the premise of masks protecting the mask wearer and worried about the supply of PPE for health care workers.The CDC said no masks early on because years of studies said masks didn't work.
The WHO does not (nor did it ever) tell the US what to do. The WHO acts as a conduit for information world wide and tries to get international cooperation regarding health emergency response.
The CDC is part of our government and is supposed to cover the national response and coordinate with local health agencies and hospitals regarding our response to an emergency. Because only the federal government has the resources or the authority to coordinate a nationwide response, that is how it should be done.