An oddity of history is on display!
Most firearms manufacturers offered "proprietary" cartridges of their own design; probably an attempt to create an ongoing revenue stream. The .38 S&W cartridge is one developed by S&W late in the 19th Century, frequently chambered in the top-break revolvers of that era and continuing into the 20th Century in the M&P series of hand-ejectors.
Colt offered their own .38 centerfire round, originally as the .38 Colt and later as the .38 Long Colt. That cartridge was officially adopted by the US Army as a service cartridge in the late 1890s, replacing the .45 Colt with a new double-action Colt revolver. The .38 Long Colt developed a rather poor reputation for stopping power in combat during the Philippine Insurrection, leading to new military trials for handguns and cartridges in about 1905.
Smith & Wesson submitted the Military & Police Model (hand-ejector) chambered for the new .38 Smith & Wesson Special cartridge, basically developed simply by lengthening the .38 Long Colt case to increase powder capacity, thus achieve higher velocities and energy.
The new .38 S&W Special became very successful, probably the most popular handgun cartridge of the 20th Century in the United States (and many other nations).
Why S&W chose to base this development on the Colt cartridge is an interesting question. They certainly could have done a very similar thing with their own .38 S&W case.
In any event, .38 S&W cases have different body diameters, overall length, and case head dimensions than the .38 Colt, .38 Special, etc. Revolvers chambered for .38 Colt, .38 Special, and .357 magnum will usually not accept the S&W cartridge (unless well over nominal dimensions in the chamber). But .38 Special and .357 magnum revolvers will readily accept the .38 Colt and .38 Long Colt, all being based on the same case head and body diameter.
Back in the 1960s there were thousands of S&W Victory Models re-imported to the US, originally made for the .38 S&W (or .38-200 as the Brits called it) and rechambered for .38 Special to appeal to the US marketplace. This seemed to work, but frequently resulted in case ruptures due to the oversized chambers.
Prior to WW2 most of the major gun makers focused on firearms chambered for their own cartridge designs, and there was no standardization to speak of. When a gun maker offered something in another maker's caliber design it was usually marketed without reference to the competitor (.44 Winchester Center Fire became the .44-40, .32 WCF became the .32-20, etc). The .38 Smith & Wesson Special is no exception to that rule, having become more commonly known as the .38 Special when seen in other maker's firearms.
It has only been since the early 1960s that we have seen much effort toward standardization in cartridge and firearms manufacture (via SAAMI). Before that it was common to see ammunition boxes describing which specific firearms their products were "regulated" for (rifle, handgun, Colt, S&W, Marlin, etc).