Bugs usually occur due to unknown defects, control flow errors, command errors, data type mismatch, missing command, etc. Sometimes, the bugs can also occur due to communication errors.
How many types of bug errors are there in software testing?
7 types of software bugs and errors.
Why an error is called bug?
Operators traced an error in the Mark II to a moth trapped in a relay, coining the term bug. This bug was carefully removed and taped to the log book. Stemming from the first bug, today we call errors or glitches in a program a bug.