The would have to be controlled by your Student Information System (SIS) which manages enrollments, if you have one.
Otherwise, if you use course self-enrolment, a workaround is to add a final activity at the end of course 1 – such as a quiz – inside which you give the enrolment key to the next course (in the quiz feedback for example, or in a label using access restrictions based on passing the quiz). Thus, only those who have completed course 1 can get access to the enrolment key for course 2.