I believe that guidance was based upon a prioritization necessity to make sure that medical first responders had access to PPE. Once the supply of PPE was great enough the guidance was also changed
The problem is they didn't say "masks work but please save them for first responders until we get more." They said "masks don't work." You can argue they may have had a good reason to lie, but you can't argue that they didn't lie.
Medical specialists were concerned about incorrect usage of masks, which may increase risks of infection. Later studies contradicted those fears somewhat.
They never said that "masks don't work", you'll find that they instead said "There is no evidence that masks work" as there wasn't yet evidence at the time. It was correct, but a poor way to communicate the situation.