It certainly doesn't "have to be equivalent to the two groups coming from different underlying populations", hypothesis testing is a probabilistic endeavor. It could be a type I error. To use your example, if the students were randomized into the two groups and nothing else was done except to give them all a math test (i.e., there was no manipulation), the significant finding would be a type I error by definition. (This is not as strange as it sounds, when subjects are randomized into groups for a longitudinal study in the biomedical field, there is always someone who wants to test that the patients really are the same on their covariates at baseline, which is logically identical to the silly situation I just described.)
On the other hand, you could look at naturally occurring groups. For example, you could assess the students who sit in the front half of the room vs. the students who sit in the back half of the room. It is perfectly reasonable to imagine (both as a former student in various classes, and as an occasional stats teacher) that students who choose to sit in the front or the back may differ in abilities, interest, etc. You could legitimately conclude that those students do come from different populations if you found a significant result. What you could not do, in that exact situation, is assume causality: either that sitting in the front makes you better at math, or that being worse at math makes you sit at the back. In addition, a significant result in this situation could still be a type I error; there is never any guarantee that a significant result isn't a type I error.
Not to belabor the point about causality, but we can form a couple more hypothetical situations / studies. Imagine we randomize the students into two groups and gave them each a slightly different version of an otherwise identical math test: one version starts with the following text, "this is a very difficult test comprised of trick questions; most students will fail it", and the other version starts with, "this is a very easy test comprised of basic questions; most students will ace it". Furthermore, imagine that the mean scores of the two groups significantly differ. Now we may legitimately conclude that they come from different populations, and may conclude that the test's introductory statement does have a causal effect on performance (although once again, it could still be a type I error). The meaning of 'come from different populations' is subtle here. The students didn't belong to some pre-existing distinct groups, rather they have become members of the abstract population of students who have read a certain emotionally charged introductory statement before taking a math test.
In our last hypothetical study, we could mix the assignment of the students by classroom seating preference with the manipulation of the test's introductory statement. If we got significant results, we could legitimately conclude that the students represent different populations, in the sense just described, but would be skating on thin ice if we tried to infer causality for the text. This is because the experimental manipulation is confounded with seating preference (among any number of other possible invisible factors). The result could be due to the text, the seating preference, something unmeasured that is correlated with seating preference, perhaps math anxiety, or be a simple type I error.