There was a severe shortage of N95's at the time, and if the public thought masks were important, there would have been an unprecedented run on PPE and the medical community would have had squat. Given that masks, particularly N95s are actually effective in a Healthcare environment ... it was the exactly the right call to make.
Get the masks to those who it will actually help, not the public for whom it will make a smaller difference.
Once production is ramped, or we have enough PPE, then it makes sense to have a pro-mask policy for the public.
From a communications perspective, it's obviously problematic, but in terms of equipment triage, it's highly rational and we actually want our leaders making these kinds of tough decisions.
The WHO and various governments should have been more efficient in their messaging however.