When you define a role, you can specify which contexts the roles can be assigned in - it is a list of checkboxes near the top of the form you get when you click on 'Edit' for a role.
Most roles (teacher, student, etc.) are designed to be assigned at the 'course' level, so go to a course, click on 'Users > Show enroled users' and then enrol users there with specific roles.