Should students have access to past exams or an exam bank? Something I never understood is how in so many undergrad classes North America, the students are allowed to have past exams that they are allowed to study over.

It never made sense to me because it is apparent that this practice could cause so many problems, especially as exams accumulate over the years, e.g. leading to inflated grades. I do not exclude myself from this practice. 

As an example, in one of the classes, I knew only a small number of students had access to an exam around that was given around 5 years ago (literally gotten through one of the student's relatives who took the exams years before), and one of the question from that past exam was very similar to another one that was given in the actual exam. This doesn't seem very fair to me.

Finally, I always felt that my work was delegitimized with access to these resources, and over the year sort of adopted a pessimistic view on learning and knowledge, seeing that so many of my peers became arrogant and prideful despite having had access to these external resources. It was not until I did grad school much later on (where past exams are virtually non-existent) did I "let go" of those feelings and regain a bit of confidence in my own capabilities.

Should students have access to past exams or an exam bank that they can study? Why does it not constitute as cheating? My background is in STEM.
As a professor, one has to assume that all past exam questions are available to students. Some student organizations debrief members after exams and capture the questions for such an exam bank. 

Some professors realize this and take action accordingly, not reusing questions, or not using enough of them to matter substantially. Others think, probably mistakenly, that they can set rules forbidding the use of such "resources". The rules will be broken by at least some of the students. I don't know of any effective way to actually prevent access to old questions. So, just assume that they are available. 

My own opinion is that the professor should just assume that it will happen and, if they want to make the test taking "fair" will make old exams available for study. Some even go so far as to give out the final exam on the first day of class, to be taken later, though I suspect that not many do that. 

But old exams are useful for honest students to study from if they don't expect to get those questions on their own exams. 

Of course, coming up with new questions each term/year adds a bit of work, but if the course is so "stagnant" that an exam from a few years ago is still being reused then the prof needs to do a better job.