You use Groups to do this.
Cohorts exist at the system level and allow you to enroll the members of the same cohort into the same set of courses, like you are doing. Inside a course, however, students can be put into Groups and the course can be set so that Group members only see each other, and not members of other groups. Groups apply only inside a specific course, not across courses.
For how to set this up, please see the documentation on Groups, especially the part of "Separate groups."
Cohorts exist at the system level and allow you to enroll the members of the same cohort into the same set of courses, like you are doing. Inside a course, however, students can be put into Groups and the course can be set so that Group members only see each other, and not members of other groups. Groups apply only inside a specific course, not across courses.
For how to set this up, please see the documentation on Groups, especially the part of "Separate groups."
Cohorts and groups are not coordinated in any way: you need to do that. You can do that manually create groups in a course matching each cohort name and put the members in, but it is more convenient to use this excellent plugin, Cohort members to groups which will automate that for you.