it's because your using 'language' as the name of the variable in your code, not 'languages', so it takes the last value of the variable 'language' in the for loop that you wrote in case of multiple languages,
just fix the variable names from 'language' => 'languages'