Dialects are primary mode of communication in Norway and Bokmal is seldom used. IIRC even when two Norwegians do not understand each other, they are more likely to use English than Bokmal.
That's a really fascinating question, and I'll reference a research paper I came across as well as do a tiny bit of speculation of my own. I welcome academic scrutiny on both of them!
First, the research paper that I'll post the link to down at the bottom. Broadly speaking, the continued presence of a huge amount of dialects (the paper references 4 broad categories and 54 local variants) can be attributed to the acceptance of these dialects in mass media produced or translated into Norwegian. If we compare that to, say, German, most news presenters or media personalities speak Standard High German, and this form of German is what they are taught in school. This means that German-speakers from around the world can consume this media without too much difficulty, but still speak the variant dialects at home in Switzerland, Austria, Luxembourg, etc.
Conversely, in Norway, while every child is taught the standard Norwegian language in the written forms of Bokmål and Nynorsk, there is no real consensus on how these words should be pronounced. Bokmål is the Norwegian language written out similarly to the Danish language (more on that in my speculation part), while Nynorsk was developed as the distinctly Norwegian take on their own language. But in spoken Norwegian, the government has not even really attempted to standardize the spoken language, instead preferring to let people keep their local dialects and distinct pronunciation in order to keep traditional aspects of their culture and a sense of decentralization alive. Norway is a large country with only about 5 and a quarter million people living in it and speaking the language. For most of their history, they had a very decentralized government with the common Norwegian identity cropping up in the latter half of the 19th century. Having an official state-approved written language is more than sufficient for everyday communication, and the dialects are still mutually understandable enough for most people's communication needs.
We'll now move away from the research paper and travel a little bit into the land of speculation on my part. I believe the proliferation of dialects comes down mostly to the unique history of Norway, and their isolation as well as an historic lack of self-determination.
Throughout much of their history, the lands that make up Norway were not ruled by actual Norwegian kings. Norway was sparsely populated (arable land was and is in relatively short supply), and the most populous trading city of Bergen could only claim about 7000 people. These numbers were reduced even further by the Black Death in the mid 14th centuries reduced this even further, and was the last real hurrah for the Kingdom of Norway founded by Harald Fairhair in the Viking Age. After this loss of population, power, and prestige, Norway was a junior partner in a personal union with Denmark, leading in part to spoken Norwegian more resembling the written form of Bokmål that I mentioned earlier. Sweden was a junior partner in this same union, but eventually fought for their independence and had their own brief time of Empire-building before making the mistake of invading Russia. After Denmark backed the wrong horse in Napoleon, Norway tried their hand at declaring independence, but we're eventually forced into another personal union with Sweden. They had their own government and public services, but still had no real freedom to declare foreign policy until their ultimate declaration of independence, and the personal union with Sweden was dissolved in 1905.
This is a very broad and vastly oversimplified version of events, but I think it's important to realize that Norway as a fully independent modern country has only existed for 116 years (minus the 5 or so it spent as a puppet of Nazi Germany). During most of their history, the language became the only way for most people to really consider themselves Norwegian. This was a way to exercise their cultural and historical identity apart from their two imperious neighbors. The other, far more populous and powerful, Norse speaking nations of Denmark and Sweden were the only real contenders for power in the area, and they never made any concerted effort into forcing the Norwegians into speaking their own particular dialects the same root language. They had no real reason to, as Norway is very remote and removed from the turmoil that is the rest of Continental Europe.
You see, there was nothing really IN Norway. They had decent mineral wealth, but not the population to exploit it. There were trade routes to northern Russia, but until the advent of the modern steel steaming ships, it was far easier and safer to take the Baltic route to Russia during the trading season. The only resource Norway has in abundance was fish, and this wasn't exactly an excellent reason for the continental powers to want to invade Norway and impose their will upon them. In fact, the major trading city of Bergen was the only city to have a major European influence in the form of Hanseatic traders from the trade-oriented city states of Germany, and this had a permeant effect on the spoken form of Norwegian such that a distinctly German accent is common in the city even today. The comedy duo of Ylvis are well-known for this, and listening to their spoken Norwegian next to that of, say, someone from Oslo is very entertaining, from a linguistics standpoint.
My ultimate point in this is that Norway stayed very isolated and very much apart from the rest of Europe. Denmark and Sweden both at some point attempted to become major players on the European stage, but Norway stayed very much apart and the people inside Norway even more so. They grew up in their isolated communities nestled at the end of fjords speaking the Norwegian that their parents spoke, and it wasn't until the advent of mass media like radio and television that the more obscure or hard to understand dialects began to die out. Even then, the history and every tolerance and acceptance to dialects in the media will probably mean it'll be another hundred or so years before even half the remaining dialects begin to die out.
The report that I reference, available in pdf form on the website if you'd like to download and peruse: https://www.researchgate.net/publication/326491611_Dialects_in_Norway_-_Between_Tolerance_and_Standardization
Short answer: Norwegians understand all other dialects, so switching to bokmål is never necessary and would feel awkward to most.
Long answer: Norwegian dialects have developed towards a written standard in the past 2-3 generations. But never to the point where the written standard has eradicated the dialects.
Before the 1970s, two things were different: Norwegian dialects were much more diverse and archaic (seen from today's perpective), and could in some cases be mutually unintelligible. There were to major reasons for this: Less travel/communications between regions, and the fact that the written standard (called "dannet dagligtale", or "educated speech" when spoken, in practice it was spoken bokmål) had a vastly higher social status and was the only one spoken in the media (like it still is in many countries). So in general, there was much less exposure to the wide array of dialects. At that time, one was expected to switch to bokmål when communicating between dialect areas, such as moving to or even visiting other places, making phone calls, etc. Especially in cities, using rural dialects would be very much frowned upon and perceived as unacceptable.
This changed in the late 1960s and throughout the 1970s, when the post-was education boom saw an increased number of rural people moving to the cities. A strong language movement had existed since the late 1800s, and since the 1950s major themes were emphasising pride in one's dialect, resisting anglification, and most importantly demanding equal rights for nynorsk.
In the 1970s the dialect argument coincided with other strong social currents such as:
This all helped lift the dialect argument into the meainstream, causing radio and tv to start accepting dialects on air (helped by the fact that all stations were state-owned), as well as theaters and -- most importantly -- the populace in general.
This had two consequences: the following generations grew up exposed to various dialects on a daily basis, and the dialects in turn grew closer in regard to vocabulary (but not phonetics). Today there remains some divide between those who's speech is close to the written standard and others, but it's generally accepted that all dialects are understandable to all Norwegians.
Today, the expectation to switch to bokmål when visiting a city would be perceived as very strange, even comical, by Norwegians younger than 60. Changing one's dialect (after reaching adulthood) is even frowned upon in some circles.
Unfortunately, I don't know enough about the historical background in Sweden and Denmark to say anything except that some of these factors probably were not in place there.
Sources:
I don't really have anything to add that the other comments haven't said already, but since one cites a report and the other two books in Norwegian, I can point you to an English-language, book-length source, if you're interested: Language Planning as a Sociolinguistic Experiment: The Case of Modern Norwegian, by Ernst Håkon Jahr (University of Edinburgh Press, 2014). It does a good job of discussing the history of the Norwegian policies that led to this situation in more depth than an article will allow, but it still keeps everything quite plain and easy-to-follow, in my opinion.