Nokia was huge as an organization and parts of that organization recognized the threat early on. The problem was at the board and executive level. These people had a blind spot for software. They thought they were still in the electronics business. Lots of people with an electronics and radio background. Not a lot of people with software competence. And they had bought into the notion that Symbian was going to magically fix all their problems.
A lot of effort was spent on looking for other solutions. And one of the things that was good (Linux) around 2005 was actually quite close to displacing Symbian as the key future proof replacement for their legacy platforms. Symbian was just rolling out for a few years and they had made a big investment in that. And management (those same people with a huge blind spot for software) backed the wrong horse.
Linux never really died in Nokia but it wasn't allowed to prosper either. Devices were cancelled or repurposed for Symbian. This happened to the N8, for example. By the time they switched to windows phone, they actually had two Linux platforms (Meego and Meltemi) and an Android phone in the works as well. Meego had one last product phone launch and the team and platform were killed in the same week. Any devices for that platform were labeled as developer phones. Nokia never marketed them as a consumer phone. Meltemi never saw any product launch at all; it was aimed at feature phones. Both were good ideas but poorly executed. Nokia killed them along with Symbian in order to back windows phone. Classic baby and bathwater situation.
And MS ended up killing the one Nokia Android phone that was launched shortly before they acquired the whole phone division. Kind of a desperate/ballsy move. I suspect Nokia did this as a stick to ensure MS followed through with the acquisition. That was their "oh we could just switch from windows phone to Android unless.. " move. Nokia was at point the only OEM that still believed in Windows Phone.
MS killed the whole division shortly after Satya Nadella took over and was sorting out the mess left by Steve Ballmer. The iphone was solidly in charge by then and the rest of the market was Android. Courtesy of lots of Linux contributions by the Meego and Maemo team.