It wasn't the memory overwriting itself that was at issue - the problem was extreme fragmentation of the data in his program.
This is an ideal system with 0% fragmentation. The dashes are used space, the spaces are free space:
|---------------------------------------- |
There's a lot of room for the doctor's program to manipulate the existing pieces of his memory in order to be efficient and quickly find the data/memories he needs.
This is more like what the Doctor's data/memory looked like when he started losing his memories in that episode:
|---- ---- ---- ---- - - - - - - --- ----- - - --- - ----|
There isn't much room to manipulate the data anymore. See that chunk of 4 dashes near the beginning? If that was his memory of Kes, he no longer has any continuous memory locations it can be moved to for fast access. That's why he could remember her one moment and forget her the next - the random actions going on were shuffling his data even further, occasionally allowing his program to quickly access to what he needed for that second, like the memories of Kes.
The Diagnostic program was complaining because this is more like what the Doctor's memory should have looked like:
|---- -- - - - --- - - - ----|
Looooots more room available because the Doctor wouldn't have filled his memory with stuff like Opera.
The Diagnostic program was for diagnosing problems, but computer diagnostic programs often will include some sort of disk defragmenter - more likely than not, Zimmerman's Diagnostic one included some equivalent which would, over time, convert example (2) to look more like example (1).
I suspect the concern about the procedure to fix the doctor was that the Diagnostic program's defragmenter was not designed to be run on a program as complex as the Doctor, and that combining the two programs could corrupt a large subset of the Doctor's data before the defragmentation process even started.
So that would be why it never happened again: The Diagnostic program is now a part of the Doctor, and it's working to prevent this from ever happening again.
(Side note, in real life, disk defragmenters aren't really needed anymore; fragmentation was a huge issue with old filesystems like the File Allocation Tables (one well-known was FAT32), but Windows moved to NTFS afterwards, which is far less prone to fragmentation, although of course it is still possible. With the huge size of hard disks nowadays, the average person will never have to run a defragmenter again. But the switch from FAT32 to NTFS didn't become common until years after the episode in question was created, with Win2000 and WinXP, so... yeah. Old technology made it into Star Trek. Although FAT32 filesystems are still around (often on flash drives) because they're the most cross-platform with Windows, Linux, OSX, and others OSes.