They failed to make the transition from enthusiast / professional users from the stylus and keyboard days of Windows Mobile 5 PDA's (the later ones with phone functionality) to the mass market adoption of multi-touch touchscreen smartphones that started in 2007 with the iPhone and then in 2008 with Android.
At first they laughed at the iPhone (there is a video of Steve Balmer of that) and then they took too long to adapt and made way too many break points along the way, which kept preventing adoption by both developers and users who wanted some continuity in their ecosystem. Windows Mobile 6 was still old-school and that's when they started to make changes, but the resulting Windows Mobile 6.5 only made superficial GUI changes in the main screens to be used with fingers, but the rest of the usage still had to be done with a stylus or keyboard as the GUI still hadn't been fully updated to the new paradigm.
Windows Phone 7 was their first serious incursion in the new paradigm, but at that point they were late (sales of handsets began in Oct 2010) and behind on features. It took them more time until Windows Phone 7.5 to add some much needed features such as copy paste and others, that the competition already had. Also, even though the system was now incompatible with the previous Windows Phone 6.5, it was also not fully modern and only supported single core CPUs. Then they went to Windows Phone 8, which was a much more modern platform, finally based on the NT core of Windows 8, but it again broke compatibility in the software ecosystem, at which point it was all too late. Windows 10 Mobile was supposed to solve it all with UWP (another break point), but at that point it was too late and the strategy of trying to use desktop users to the point of their frustration by shoving a mobile GUI in their faces starting with Windows 8, didn't work and the damage had been done. iOS and Android were too far ahead for developers to consider investing the time and money on a platform that had had too many changes in the past and was super late to the party.
I don't think that they gave up though. In a few years they will drop the NT kernel, and adopt the Linux one, at which point Windows will be like Android, built on top of Linux and at that point they will try again. Right now they are pursuing the "if you can't beat them, join them", so they are making their applications and services available on the competition, in order to make money, stay visible and relevant. When the time comes, they will make another push, with tablets and then eventually smartphones, even if it takes them 20 years, they will keep trying, slowly, but surely.