First, because people make mistakes in the code they write, It’s very difficult to account for all possible inputs in any but the simplest of programs. Sometimes you know a bug exists and how to fix it, but it isn’t worth the time you’d spend fixing it. For example, your spreadsheet program probably doesn’t correctly handle dates from 500 years ago.
Second, because people don’t communicate perfectly with each other, and no single person can understand the whole situation. You can have no bugs in your own program, but still get issues because your code relies on the work of hundreds of other people.
Third, even computers aren’t perfect, it’s entirely possible for your program to crash because a cosmic ray flipped a bit in memory somewhere.
Latest Answers