I am not a teacher, but the correct answers here are:
1. "to" suggests direction, "at" suggests presence (I hope I am calling it correctly), as in: I am at my friend's at the moment. At is not usable in the sentence you provided.
2. "by" suggests that the teacher is the performer of the action of punishing. If he were to give you something, you would get it "from" him.
I hope I am making sense. I am sure the teachers here will explain this more comprehensively.
Student or Learner