Why Are Companies Using These Ridiculous Tests to Screen Candidates?

I recently applied for a tech-related position that required a computer science degree. (very well known company non tech) The application process included an almost two-hour assessment: an aptitude test, followed by pattern-matching games and multiple stages of memorizing dot sequences on a screen. Despite completing these tasks, I received a rejection. It's frustrating that such tests, which seem disconnected from the actual job requirements, are used to evaluate candidates. As someone nearing graduation and actively seeking employment, I plan to avoid companies that rely on these types of assessments in the future.