Computer bugs are named after literal moths getting stuck in the electronics in the 1940s hence the term debugging.
Are moths bugs though?
That's a common misunderstanding due to inaccurate reporting of tech in the mainstream media back in the day.
The earliest surviving reference to unexpected errors in an electrical device being called bugs dates back to ~1900 (in a magazine), but it's used without explanation because it was a commonly (by people interested in tech) used term by then. It probably goes back to the early years of the electrical telegraph system in the mid 19th century.
The misunderstanding probably arose because (like today) the mainstream media frequently made a bad job of reporting on tech stories.
What happened was this:
An early computer was returning inaccurate results for a program. The people at the site dry ran the code and got the right results, fed it to the computer and got wrong results. So a hardware problem was a good possibility. Early computers were a bit limited on reliability. The computer used thousands of vacuum tubes and loads of cabling connecting them. It was large enough to walk around inside the computer, partly because it had to be for the tubes and cooling and partly because it was necessary for techs to be able to walk around inside the computer to replace failed tubes. So the techs painstakingly went through everything to determine exactly where the error occurred and what parts of the computer were being used at that exact time, to narrow down where inside the computer the problem was. They walked around inside the relevant part of the computer...and found the body of a moth that had flown in and touched a live contact that killed it. The body of the moth was affecting the resistance of that part of the circuit and causing the incorrect results.
They removed the body of the moth, taped it into the site's logbook and wrote a jokey comment about this being the first case of a bug being caused by a bug.
A bit later, Grace Hopper (who wasn't there at the time and wasn't involved) recounted the story as an amusing anecdote about computers. She was famous, which drew some attention to the incident. Reporters put 2 and 2 together to reach the usual answer of "I don't care what's true and I don't have time to find out anyway" and reported it as Grace Hopper discovering the moth and creating the term "bug" to describe an unexpected error in a computer. She never claimed that and publicly stated several times that the reporting was wrong, but to little effect.
The logbook's in a museum now. There's probably an image online...
...yes, here it is:
www.si.edu