Hello Kayliana,
Since you posted under Microsoft Education category, and the class my understanding is a class team in Microsoft Teams for Education, please clarify if I misunderstand your scenario, thanks.
If so, according to my tests and research, if you were added into a class team in Microsoft Teams, you cannot directly leave the class team by yourself, and you would need to contact the class team owner to help you remove from that class. You could click the three dots (...) after the class team name > manage team > owner you would see the class team owners ( your teacher) then you could contact him to help you remove the class, thanks.
Please feel free to let me know if you need any other help, thanks.
Best Regards,
Oliver