The original PC-DOS operating system was written by a guy called Tim Paterson, not Gates or Allen. Paterson wrote it while working for Seattle Computer Products [SCP] for their own 8086 CPU board (a micro computer kit component). Microsoft bought DOS from SCP and hired Paterson to adapt it for the IBM PC. They then sold it at a massive profit to IBM and other PC makers. Later, SCP successfully sued Microsoft for misrepresenting the intended use at the time of the sale.
SCP seems to have regarded their operating system as something of a joke because they had originally called it the "Quick and Dirty Operating System", QDOS. They renamed it more sensibly as 86-DOS, probably when they learned that Microsoft was interested in buying it. For the IBM contract Microsoft kept the DOS part of the acronym and said the "D" stood for "Disk".
"DOS" was quite common in names of operating systems in the early days, which has led some to assume that Gates was responsible for them all. Most had no connection. Apple had "Apple DOS" and Amiga had AmigaDOS for example, and had nothing to do with SCP, Microsoft or IBM. All these DOS's were relatively crude pieces of software compared with modern operating systems, or even others at the time.