This can be accomplish by Self Enrollment feature of Moodle.
First you have to enabled the Self Registration feature which you will find under Plugins> Authentication>Manage authentication> Self registration.
Now enable the self enrollment method in the courses which you want to be available for students after registration.
You can enable it by going through
Course administration> Users> Enrollment method
Click on the eye icon to unhide the Self enrollment process. I hope this will help you.