What does "classes" mean in the second line?
I'm a little confused. In your post, "classes" only appears in the first line. "Class", singular, appears in the second, but you don't ask about that. Am I to understand that you understand the meaning of one but not the other? Actually, come to think of it, they don't seem to mean the same thing at all.
In the United States, a "class" in school can mean different things. All of the students of a certain grade level constitute a class, but a class can also mean a group of students that meets in a certain classroom on a regular basis with a certain teacher. At my elementary school, there were four teachers for every grade level. At the beginning of the school year, we were each assigned to a certain teacher, and for the whole year, we would spend all day in his or her (usually her) classroom five days a week and that one teacher would teach all the subjects. In first grade, I was in Mrs Buehler's class and Kathy Willis was in Miss Thompson's class, but in third grade we were both in Mrs Wilcox's class. In high school, things were different. Each teacher taught only one subject, so one might have as many as eight different classes in a day. Every fifty minutes a bell would ring signalling the end of the class period and we had five minutes to go to our next class. Also, there might be students from different grade levels in the same class.
I imagine there are a lot of differences between elementary schools in the United States and in Italy, let alone the Italy of 136 years ago, so I'm going to have to make some educated guesses as I attempt to answer your question. I was also put off a bit by some of the wording and punctuation. (At first I thought this was due to a problem with the translation, but I finally realized that the author had set out to create the effect of an eleven-year-old boy writing in a diary.)
Getting to your question, the word "class" seems to have the same duality of meaning for the author (or, more probably, the translator) as it did for me. The narrator, Enrico, is in the third class, meaning grade level, and he is assigned to Master Perboni's class, meaning classroom group. His younger brother is apparently in the first class (grade level) and is assigned to Mistress Delcati's class (classroom group). As it was with my school, each grade level has several classroom groups.
So the passage you cited:
At ten o'clock we were all in our classes: fifty-four of us; only fifteen or sixteen of my companions of the second class, among them.
means that there are fifty-four students at the third grade level, divided among some unknown number of classroom groups, one being Master Perboni's. Of the fifty-four, there are only fifteen or sixteen that Enrico remembers from the second grade. At ten o'clock, all of the students were assembled in their various classrooms.
How did I do?
PS: Thank you very much for citing your source.