The middle term is the one that appears in both premises - in this case, it is the class of backpack carriers. It is undistributed because neither of its uses applies to all backpack carriers. Therefore it can't be used to connect students and my grandfather - both of them could be separate and unconnected divisions of the class of backpack carriers. Specifically, the structure of this example results in affirming the consequent.

However, if the latter two statements were switched, the syllogism would be valid:

All students carry backpacks.

My grandfather is a student.

Therefore, my grandfather carries a backpack.

In this case, the middle term is the class of students, and the first use clearly refers to 'all students'. It is therefore distributed across the whole of its class, and so can be used to connect the other two terms (backpack carriers, and my grandfather).

Note that a fallacy of the undistributed middle is rarely so obvious. Another example of its use could be in the argument, "Eric Harris and Dylan Klebold, two young men who loved the violent video game DOOM, went on a sociopathic shooting rampage at their school. John Doe is also a noted fan of violent video games, and has even argued that developers should not tone down the graphic content in their mass-market games. It is therefore highly recommended that John Doe be monitored for signs of sociopathy".