Why does Windows 10 return the version number 6.3?

Because it is picking up the fact you upgraded from Windows 8.1. The method you are using is looking at the registry. It is working as intended. There is a more appropriate function then using the environment variable to determine what operating system is being used. I can't provide code since this isn't Stackoverflow

– Ramhound Aug 26 at 1:12

That's the answer in a nutshell. During the upgrade, the registry doesn't change the build number from the old to the new one. It just sticks.