This is because cmd can only run commands specified in the environment variables (in this case npm). This path is added when you install node in your system globally.
When you add the complete installation path, e.g. C:\Users\\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng to environment variables and rerun cmd, it will accept ng as a command. Your environment variables must contain both npm and ng paths
Alternatively, you can also use Node.js command prompt to run ng commands.