It does not take a million lines of code for an operating system. UNIX did it fine with less than 100,000 lines of code for many, many years. A twenty year old UNIX system still does most things better than any Microsoft operating system has ever done and is more stable as well.
Of course, that was in the years when efficient programming actually meant something. Most modern programmers have no idea, nor desire, to write truly efficient code. Of course, most modern day programmers are not system programmers anyway.
Microsoft's operating systems are more like an application than an operating system. Most of Microsoft's code is tied up in the GUI. The GUI is a shell which is not part of the operating system, even though Microsoft would have everyone believe it is.
A lot of the problems can be traced right back to the human resources departments. Those guys have no idea how to hire a systems programmer.
Now, if you are talking about supplying all the utilities and applications with the operating system and writting those, then you are into seriously large amount of code work.