There are many reasons. Bad memory, not enough memory, running Windows, overheating, “dirty” power, not enough CPU to do all that you want it to do in a timely manner (my most common one on my systems; I flog them hard), it hates you, loose wires….
I can think of a lot more reasons for a computer to freeze, but I think I will stop with just the list of things that pooped into my head within 30 seconds of reading this question.
@CaptainHarley I have 6GB of RAM and enough hard drive space to cache every page I visit and have yet to freeze my browser (except for the times I tried running Safari, which freezes before even fully opening and then crashes like Dale Senior a couple of minutes later without having done anything useful) so I can attest to the fact that a big cache helps. On older systems, I used to be forced to run with a teeny, tiny, piddling cache and had problems.