All kinds of things can go wrong when programming. Sometimes you don't have control over them. Very often you can't reliably predict them. You get better at knowing yourself and what to watch out for with experience, but even the most experienced programmers run into unexpected issues. And have bad days or weeks.