Always, always, always read the manual of the tools you use. They will educate you on how they work and give you an idea about their weaknesses.
The smb_version scanner connects to each workstation ... and
determines the version of the SMB service that is running.
... remote OS detection using TCP/IP stack fingerprinting ...
Nmap compares the results to its nmap-os-db database of more than 2,600 known OS fingerprints and prints out the OS details if there is a match.
So, as you can see, the
smb_version scan connects to the Windows SMB service and asks it what version it is.
nmap analyses the TCP/IP traffic and makes a guess.
Never, ever, use a tool blindly and take the answers at face value.
nmap -Oworks to detect the OS?
man nmapwill give you a detailed manual for nmap, whereas
nmap --helpwill only give you a summarised version which can lack a lot of valuable detail. To get more familiar with the SMB protocol, check out the official Microsoft documentation: docs.microsoft.com/en-us/windows-server/storage/file-server/… Official documentation is always the first place to start understanding a tool or service.