My classmate developed a roll of 100 TMAX 35mm B/W, and some of them came out looking flat, but not all. What could account for this?
If you mean that some frames are less contrasty than others (as opposed to frames having obvious development issues, like streaking, "lakes", tide lines or gradients), then the problem is exposure, not development per se.
It could be that some of the scenes had a significantly smaller contrast range than others. It could also be that the "flat" frames are significantly underexposed. To a point, either of those can be corrected by using a paper with a higher contrast grade when printing. If you're scanning, then working in a higher bit mode will allow you to increase the contrast range even more without damaging the image tremendously.
The idea of the "perfect negative" is almost incompatible with roll film shooting. (I say "almost" because one can control exposure and contrast pretty closely in a studio environment, and it is possible, though a complete pain in the butt, to dedicate different rolls of film to different contrast ranges, rewinding and reloading them as necessary and keeping track of the frame counts.) In the average use case, you're sort of stuck with a one-size-fits-all scenario, and as with clothing "one size fits all" really means "one size fits that one size; everyone else needs to cover up the waistband/hems with something". With something like the Zone System, designed with sheet film in mind, each negative will get its own custom-tailored exposure and development or (barring that sort of dedication) at least an off-the-rack exposure and development that's a pretty close fit.
If your development process is good for a scene that has a six-stop range of brightness between the interesting highlights and the interesting shadows, but the scene you're shooting only has a four-stop range, the negative is going to look "flat", and will print flat on a #2 paper. It might print okay on a #4 paper, though. By the same token, if the scene has a nine-stop range, it will look blocked in the highlights and thin in the shadows, and you may or may not be able to rescue it using a #0 paper.
Metering is something one really has to learn to do well. Our meters tell us what's going on at "middle grey" (different meters and metering schemes will interpret that slightly differently), so we need to determine for ourselves where the important highlights and shadows lie in the scene, and what sort of contrast range that will give us. Although it's a bit cliché, we really do expose for the shadows and develop for the highlights. You need to let enough light into the camera to expose the film enough to record the shadows (and take it for granted that there will be more than enough light to record the highlights). To a first approximation, any development will reveal the shadow detail; the amount of development will determine how black the highlight areas will get. When all we meter is middle grey (Zone V), all we know is that that tone will wind up in the middle of the contrast curve. It tells us nothing about the highlights or the shadows.
Now, before panic ensues, I want to point out that the "ideal negative" isn't always the ideal negative. Not every picture needs to go from almost paper white to almost Dmax. And not every picture that hits those tones is going to look like the "ideal"—a high-key image may have only a few very small spots of deep shadow, and look "flat" elsewhere. That's not a failure; it's kinda the whole point of the exercise. If the negative looked "right", then you'd have to correct the image when printing, either by using a really soft contrast grade (that only takes you so far), by severely underexposing the print, or by underdeveloping (hard to do consistently under safe lights and when you can't allow dry-down before the stop bath).
So flat negatives may or may not be a problem. They may come from exposure errors, and you can learn to fix that at the moment of taking. They may come about as a simple consequence of using roll film under vastly different circumstances from frame to frame, and you may decide to juggle rolls (each of which will be developed differently) or simply live with it and use different paper grades to print. They may indicate simply that you've deliberately taken a low-contrast picture, in which case there's nothing to do but to sit back and enjoy. A bit more experience will tell you what's going on when it happens. Just don't get caught up in chasing an ideal that's inappropriate for your image. If it ain't broke, don't fix it.