Set up to fail classes The last two semesters I've had classes where I've met all prerequisites. Yet upon the second week or so (when its too late to drop) I realize the entire class is based off another class which was not a prereq. I think I'm a good student but I'm struggling so much with things the other students do with ease because they've already learned the material. I can't keep doing this every semester, its very discouraging and draining. How do I avoid this or what should I do? I could take the said "hidden prereq.", but this wouldn't help me this semester or the next. In fact, it would only help me in my last semester of undergrad; assuming it'd be helpful at all at that point. Is this common in grad school?

EDIT:
I am following my schools recommended academic plan to a T. We have a laid out course plan to take course A in semester 5, course B in semester 7, etc. I'm 2nd semester Junior, 6/8 overall. You can deviate but I have NOT done that (at least for the courses I'm complaining about). I have not changed majors, institutions, nothing weird. I'm honestly surprised this is not a common thing. To be specific, I'm taking Computational Astrophysics which requires an intro astro course and vector calc + differential equations. I've taken a recommended course in the past labeled as Math for scientists and engineers (also labeled as a continuation of vector calc + diff eq) yet it relied almost exclusively on linear algebra and we never once did a real world problem. I have not taken linear algebra, the only matrix related math I ever took was a brief intro in highschool. NOTE that this computational astro class is specifically for astrophysics majors (me) and the astrophysics curriculum excludes linear algebra and any classes which require it. In general, this course requires way more programming skills than I have learned from my courses, the teacher even said so, although I might manage as I have gained some experience with coding through research I've been doing. Classmates of mine who have taken the same classes are either cheating or dropping out of the class because of how ridiculous it is (they havent gained coding experience in research). I refuse to cheat though because I want to learn and it will help me in my research (also ethical reasons obviously). I state the last bit to show the severity and how I am actually one of the lucky ones (hopefully I dont eat my words and fail).

Thank you for the suggestions to narrow the question, I know its broad.
It's common that the listed prerequisites do not necessarily encompass all the knowledge that is needed, or useful, to succeed in the class.  Sometimes this is sloppy design or laziness about updating the formal prereqs.  Sometimes it's because Course B needs only a small amount of material from Course A, so rather than make Course A prerequisite (which reduces students' scheduling flexibility), they assume that if necessary, the student can study this material on their own.  There are other possible reasons.

The professor will usually know what courses a "typical student" would have taken before this one, so they might assume that students know the material from those courses, even if they are not prereqs.  If you are following an unusual schedule, or changed majors, or transferred from another institution, this can lead to trouble.

So if you are in any of those situations, or otherwise suspect that this might be an issue, the best approach is to talk to the professor before you enroll in the course.  Tell them what courses you've taken, and ask if they think you have sufficient preparation for the course.  They might recommend that you wait and take some other specific courses first.  Or, they might suggest that you study certain topics on your own before the course starts.

However, it is also an important skill to be able to fill in gaps in your knowledge on the fly.  Comparing yourself to the other students is probably not useful.  But if you feel there are a lot of necessary things you don't know, make a plan for how you are going to learn them quickly.  The professor can usually help you with this.  Accept that you may feel you are behind for a while, but after a few iterations, you'll have confidence that you can catch up.

This is likely to continue to happen in grad school, perhaps more so.  In a graduate program, the students have usually come from a wide variety of different undergraduate programs.  Grad courses may assume knowledge that is often learned in undergrad programs, but any given student is almost sure to have some gaps.  Again, part of success in grad school will be learning to fill in those gaps for yourself.