Well if you have been yelled at by the same teacher in the past then I guess when something happens, the teacher would automatically assume its you. It happened to me and other people I know in school a few times
They're teachers, not detectives. Usually it just looks like you did something, or you're acting like you may have been a part of something. The important thing is the teacher has to be in power in the classroom and sometimes they need to push it a little to keep the class under control.