Set up to fail classes
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.