Laravel关系多对多不正确的返回计数

I have a User model that applies both for trainers and studenst. In my business logic Trainers have students assigned for a certain Unit, so i built a many-to-many relationship among them

public function students()
{
    return $this->belongsToMany(User::class, 'trainer_student',  
    'trainer_id','student_id');
}

    public function trainers()
{
    return $this->belongsToMany(User::class, 'trainer_student','student_id', 'trainer_id');
}

Both in the User model. I checked the DB and there are 8 students related to a trainer for a certain Unit.

"trainer_student" Table Photo.

So i did this query with Tinker:

$trainer = User::findOrFail(21);
$trainer->students()->pluck('id');

Output.

But if i query like the usual way:

DB::table('trainer_student')->where('trainer_id',21)->pluck('student_id')

Output.

What is going on? Why the relationship shows less students? What am i doing wrong?

Thanks!