A common misconception is that a software bug is called a bug because of an actual bug – a moth – that got stuck in Harvard University’s Mark II calculator in 1947. The story goes that Grace Hopper found it, taped it inside a logbook with the words “First actual case of bug being found”.
In reality Grace herself didn’t find the bug – somebody else from the team did – nor did they coin the term bug because of that event.
American engineers have been calling small flaws in machines “bugs” for over a century. Thomas Edison talked about bugs in electrical circuits in the 1870s. When the first computers were built during the early 1940s, people working on them found bugs in both the hardware of the machines and in the programs that ran them.
💁♂️ FYI: The logbook has been preserved and is now part of the collection at the Smithsonian (but not on display at the time of writing).
What seems to be legit however is the history of the term software patch. Back in the day when punched card coding was all the rage (although …), one actually had to put a patch over a wrongly punched hole (and punch an extra one somewhere else) in order to fix a bug.
Wikipedia tends to agree with this, even stating that whole sections would be replaced when needed:
Historically, software suppliers distributed patches on paper tape or on punched cards, expecting the recipient to cut out the indicated part of the original tape (or deck), and patch in (hence the name) the replacement segment.