Sieves vs. Trial Division
Generating a list of primes and testing a single number for primality are different enough problems that they call for different algorithms. Listing every prime up to a limit N is efficiently done with a sieve (like the Sieve of Eratosthenes) — starting from a list of all numbers up to N and progressively crossing out multiples of each prime found, which is far faster than testing each number individually when you need the whole list.
Testing whether one specific, possibly large number is prime is a different task, typically handled by trial division — checking whether any integer up to the square root of the number divides it evenly. You only need to check up to the square root because any factor pair has one factor at or below the square root and one at or above it, so checking beyond that point is redundant.
Prime numbers matter well beyond number theory coursework — they're the foundation of RSA and other public-key cryptography, where the difficulty of factoring the product of two large primes is what keeps the encryption secure.