Mistake and error are synonyms; they’re usually interchangeable. However, the subject’s intent is implied in a “mistake”, so it’s most often applied to situations where a person has made the error and might feel remorse or shame. “Error” is applied more often to machines but can apply to human error as well.
“I made a mistake” and “I made an error” both make sense, but calling it a mistake better communicates that it wasn’t your intention.
“The computer had an error” is correct, but “the computer had a mistake” sounds strange.