Geography and population are part it, among other things. Places like the Maritimes and New Zealand are examples of places that controlled the virus, but most places don't have the equivalent situation. If New Zealand was a province in the middle of Canada somewhere the story would have been different, same for the Maritimes. The Maritimes are connected to Canada via a small section of border between NB and Que, with only a handful of roads in and out and they were able to set up checkpoints. The Maritimes were diligent in enforcing quarantines, but part of their success could be related to population, economy and workforce as it much more difficult to enforce quarantines given the sheer number of people and migrant workers traveling between or through provinces like Ontario and Quebec. The amount of travelers or workers coming in and out of Alberta or through Alberta is magnitudes higher than that going in and out NB and NS. Those provinces also don't have the large urban centres of Que\Ont\AB\BC, which is where most of the cases have been. The land area of the maritimes is small, but the population is more rural and largely static.
With that said, they also did other things better than the rest of Canada like instituting the masks sooner, and being diligent about enforcing quarantines. I also believe the mind set to fight this virus is also better in NB/NS than other parts of Canada. Knowing what I know about the Maritimes, it's quite likely their sense of community is better than other virus hotspots in Canada where the populations are more urban, less rooted and more transient.
Here in Alberta leadership has been a problem, though I sometimes think the leader we have is more of symptom of the problem - the problem being that we too many selfish and ignorant people.