How do I avoid mydomain.com/node/1 or mydomain.com/node/4 is used? I am using the Pathauto module for creating user-friendly and SEO-friendly URLs. 
Therefore, I do not want and there is no need that the "old URL" like mydomain.com/node/1 or mydomain.com/node/4 is any longer public. So, how do I hide this and make only the path aliases public?
You need to create patterns for pathauto and go back to those nodes and save them, ensuring “generate new alias” is checked off on the node form.