Are you sure about that fact? Pharmacists went on strike in Netherlands this year. Another reply mentioned Poland. It seems there's no EU rule, or maybe it's more that some still need to be open.
The majority of what a pharmacy provides is repeat customers anyway. Despite regular customers planning badly pretty much all the time, the majority gets their medicine for a minimum of various weeks.
The participation of the strike in Netherlands wasn't high. It was pretty last minute idea by one frustrated worker. The reason was the increase in the aggression towards the people working in a pharmacy.
Poland is not part of it then.
What does have to happen is that emergency or base services are sustained. That is the one 24h pharmacy. All others can just close.
Similar with doctors in hospitals, as long as emergency service works fine strike is allowed.
Fun fact: in most of the world, medical personal like pharmacists can't go on strike.