In any complicated system, there is always some scope for error. When I program on my computer, the system computes perfectly each time. 1+1 always turns out to be 2. We take reliability of the computer almost for granted. What gives modern computers it's reliability? Are there no errors in computation, or errors, if any, are corrected by some means?
Computers rely on physics. Transistors have some known characteristics, given some assumptions on making process. Parts that does not meet the exepected characteristics are just trashed (or sold with lower expectations, usually lower max frequency).
This ensure that computations are correct while complying operation conditions (stable power supply, EMC, ...). The whole systems are built to meet those requirements. When you use very cheap equipment (often a cheap power supply), you may face some computer crashes, as you do not meet system requirements (power supply stability) anymore.
Sometimes, external conditions make expectations unreachable. In aeronautic and aerospace, systems have to cope with cosmic rays that may disturb their behavior. In such case, several similar systems are used in parallel, to be able to maintain operation when one system has errors.
Also, some transmissions and storages are known to be unreliable, and Error Correction Codes are used to fix the data after reception.
So systems are designed to prevent errors to happen in almost every cases, using a broad range of dedicated methods. Working in consumer electronics, I have some failure rates on the hardware around 10 faulty parts per million in the first year of use. This is much better than the mechanical parts or the software, but not perfect (even if it's too good for the consumer market. Average return rate on consumer products is around 1%, 100 faulty parts per million would be acceptable on this market).