As others have suggested, this happens in some cases because the teacher is simply a "control freak." But there is, in fact, a legitimate reason why other, more reasonable teachers still insist that students not leave until they are "dismissed" by the teacher, not the bell. When the bell rings, the teacher may be just about to give an instruction, make an announcement, or explain an assignment. If half the class goes rushing out the door simply because "the bell has rung," they miss important information. In the uproar as students race for the door, gossiping, packing up their book bags, and turning their cell phones back on, nobody can hear the teacher yelling, "Your worksheets are due tomorrow." Ten people were out the door and down the hall anyway, and couldn't have heard the instruction no matter what. When the teacher steps in front of the class the next day and starts collecting the worksheets, a third of the class gets snitty and complains that "nobody told me." They run to the principal and run to their parents with complaints about "that mean teacher who never tells us when our papers are due." If the teacher could say to the students, "It is your responsibility to know everything I say in class, so if you run for the hallway when the bell rings, it will be your problem," that would be one thing, but that's not the way it works. The teacher (and the principal) get bombarded with complaints from students and their parents who insist that the teacher is being "unfair" and "nasty." So, the teacher insists that everyone sit and listen until it is clear that they all had an equal chance to hear the assignments, instructions, and announcements. When you get to college, there are no more "bells," it will be entirely up to you when you jump up and leave a class, and you will be personally responsible (as will all your classmates) for knowing what goes on. Soon, "waiting to be dismissed" will not be a problem for you.
This is also a health and safety issue. The teacher is ultimately responsible for any accidents that occur when the class is present or leaving. A mass stampede for the door causes accidents to happen. The teacher has to take stock of the situation, and to end the class in a managed and controlled manner simply to minimise risk. I have been a teacher for 24 years.