Your second sentence:
私にのクラスに鈴木さんという名の生徒が5人がいるので驚いた。
is not correct. You don't use two が's that way. You'd instead say:
私のクラスに鈴木さんという名の生徒が5人いるので驚いた。
"Numeral + counter", such as 5人, 2個, 3回 etc., can function adverbially. You'd use it like this:
生徒がいる。 There're students. → 生徒が5人いる。 There're five students.
りんごを食べる。 I eat apples. → りんごを3個食べる。 I eat three apples.
山田さんに会った。 I met Yamada-san. → 山田さんに3回会った。 I met Yamada-san three times.
も, used after a numeral and counter, means "as many as" "as much as". You'd use it this way:
生徒が5人もいる。 There're as many as five students.
りんごを3個も食べる。 I eat as many as three apples.
山田さんに3回も会った。 I met Yamada-san as many as three times.
So your first sentence:
私のクラスに鈴木さんという名の生徒が5人もいるので驚いた。
means "I was surprised because there were as many as five students named Suzuki in my class."