Not quite true. DOS programs were not automatically given all memory. DOS programs needed to allocate various memories (Conventional, EMS, XMS memory) via API specific to each type. DOS programs running under Windows 95 and later were presented with a DPMI compatible API if they so choose to use. DPMI DOS Extenders were intended to provide DOS compatibility for 16-bit and 32-bit Protected Mode applications. Memory allocation was just one service type they provided. Some also provided virtual memory or Win32 API emulation.
https://fd.lod.bz/rbil/interrup/dos_kernel/2148.html#sect-29...
https://fd.lod.bz/rbil/interrup/memory/2f4310.html#sect-4815
https://fd.lod.bz/rbil/interrup/memory/673f_cx5145.html#sect...
https://en.wikipedia.org/wiki/DOS_extender#DOS_extenders