You lost Legion because even though he was loyal and a tech specialist the second fire team leader was either not loyal or not a fit for the job --> tech specialist dead.
You lost Grunt because the second time you choose a second fire team leader he dies unless he is loyal and fit for the job or Miranda (doesn't have to be loyal).
Mordin died because your overall hold the line score was too low at the door. Each person has a rating for holding the door. Add them all together and divide by the number of people that hold the door. If the result is under a certain number someone will die. There is a priority list of who dies first. Mordin is the first on that list.
For all detailed info on the suicide mission go the bioware forums. Everthing is explained
here.