Six semantic roles — कारक — are defined in the first quarter of chapter 1.4, purely by what a participant does in the sentence, with no mention of any case ending: कर्ता is the independent one (, 1.4.54), कर्म is what the agent most wants to reach (, 1.4.49), करण is the most effective means (, 1.4.42), सम्प्रदान is who the action is aimed at (, 1.4.32), अपादान is the fixed point something moves away from (, 1.4.24), and अधिकरण is the locus (, 1.4.45).
Only afterwards, in 2.3, does Pāṇini attach a vibhakti to each role — and every one of those rules is conditioned by , 2.3.1: "[only] when [the role is] not already expressed." A verb's own personal ending always expresses exactly one kāraka in a sentence — the agent, in the ordinary active voice. That kāraka is therefore already "spoken for" and does not get its kāraka-vibhakti; instead the noun just states its own meaning, gender and number, which is what प्रथमा is defined to do (, 2.3.46).
Watch it flip
Nothing about "the teacher" or "the fruit" changed. What changed is which role the verb already carries — and the case system fills in exactly the gap that leaves. That is the whole content of "the seven cases are not the six kārakas."