there were two reason health officials said that just prior to pandemic starting.
First, scientists at that time didnt about the asymptomatic spread and pre-symptomatic spread of covid.
Second is that there were no consumer grade masks available, only medical masks in early 2020. The medical masks had to be reserved for health care workers, because it would be catastrophic if health care workers ran out of masks.
Later after it was understood the benefit of reducing spread of covid by wearing face covering for general public, then these types of consumer masks were recommended.