This is the plot of 'Neuromancer'. The security A.I. and the hacker A.I. were... wait, spoilers.
The discipline of information security is about reducing the threat surface area. Think about it like actual surface area: limit the number of ways the outside can reach the inside. Information security specialists also perform their own periodic penetration testing, trying to identify weaknesses. It is well-known that people are the most often abused weak point, and penetration testing includes people. Additionally, information security includes imagining that someone does break in and mitigating how much damage can be done by an intruder: this includes encrypting data in transit, encrypting data on the raw disk, encrypting specific files (like layers of armor), multiple accounts with limited (the concept is called 'least privilege' and involves only having access to systems for which you have a demonstrated need-to-know) and non-overlapping privilege, and protecting accounts by only allowing logins from specific locations (like Sensitive Compartmented Information Facilities (SCIFs)) or only at specific locations, and not necessarily making every part of the system available from every other part of the system.
"Erasing" a hack involves deleting or editing logs or records that recorded the attack. While the attack is ongoing, every activity on all machines is being recorded (as ridiculous as that may seem). These logs are being monitored constantly by algorithms and by people. If an intrusion is detected, the response depends on the attack vector -- if someone is trying to attack the account, disable the account; if someone is taking advantage of a computer, revoke it's trust certificates (essentially detaching the a previously trusted computer from the network); shut down the app; or, if required, shut down the whole system - some security environments include virtual machines (VMs) that are intended to be disposable in the event they appear compromised or infected, only to be rebuilt from a trusted repository - in fact, disposable VMs are one of the security concepts behind apps on cellphones.
The hacker, as others stated, is looking to exploit any vulnerabilities. It could physically steal disks and work on decrypting the data. It could also exploit zero-day exploits: gaping flaws in the software environment that no one knows about yet. These may or may not avoid logging, because it's taking advantage of a gap between components.