From what I recall, Windows 95 and 98 shipped with MS-DOS 7.0, which was not released separately but was easily extracted and could run on its own. It included support for long file names.
Windows 9x supported long filenames by overriding DOS instruction to provide it, so they only worked while Windows was running. If you rebooted the PC in MS-DOS-only mode LFN wouldn't work.
There were a bunch of TSRs that added support though. Here is one i used recently on a retro PC to install Free Pascal for DOS (which, despite being for DOS, requires long filename support to install - though depending on which units you use, it can work without it afterwards):
IIRC they don’t have to exist on modern Windows on NTFS (there’s a switch somewhere that turns them off), but they’re still on by default for compatibility reasons (Windows 10 can still run DOS and 16-bit Windows programs, after all).
On FAT filesystems (still used on things like SD cards, although ExFAT’s starting to take over), 8.3 names can never go away.
NTFS is a bit funnier in that aspect than most people realise.
Effectively, you can have multiple "name" attributes on the FILE structure (which describes any kind of object in NTFS), and those names have associated "namespace" to them (or "kind"). I think ntfs.sys enforces that there's only one name per namespace, but I do not remember offhand if it was made impossible in the structure itself.
The namespaces available include at least 3 - native WinNT (16-bit Unicode, long file name), DOS-compatible (8.3 - this is where compatible names with tildes are put when generated), and POSIX (different set of allowed characters, generally 8bit with encoding ignored iirc, long file names). If you handcraft the file, you can generate one that has all three completely different, resulting in different file names seen by different APIs
> IIRC they don’t have to exist on modern Windows on NTFS (there’s a switch somewhere that turns them off), but they’re still on by default for compatibility reasons (Windows 10 can still run DOS and 16-bit Windows programs, after all).
You can disable it, but realistically it won't make a performance or efficiency difference (only reason go mess with it really), and lots of things still break if 8.3 compatibility is disabled or stripped. On occasion, this had included weird first-party errors, too.
In theory, there are tons of things that shouldn't matter any more either, like spaces in filenames, or variables like PATH being longer than 2047 characters, but it all still ends up somehow breaking various things over time.
There were a bunch of TSRs that added support though. Here is one i used recently on a retro PC to install Free Pascal for DOS (which, despite being for DOS, requires long filename support to install - though depending on which units you use, it can work without it afterwards):
http://adoxa.altervista.org/doslfn/