I was replacing a BC548 with a BC639 without paying too much attention to datasheet details except the current rating. Obviously the circuit did not work too well until I checked the correct pins. Is there some manufacturing related reason or why the pins vary between two NPN transistors?
They are standardized.
With the flat part facing you, the left most pin is pin 1, the middle one is pin 2, and the right one is pin 3, and you'll not find a single TO-92 device anywhere that does not follow this standard.
There is no standard pin mapping because TO-92 is a package, not a device, and transistor dies are devices, not a package. You should understand that semiconductors are not passive devices that are one single object like a resistor or capacitor. They consist of a semiconductor substrate (silicon, germanium, others). That die is usually (though not always) further packaged into a standard package type listed in the JEDEC or JIS standards to provide environmental protection, passivation, immunity to the photoelectric effect, and enhanced thermal specifications. As long as the number of connection pads to be externally connected match the number of pins available for a given package variant (and the die isn't too large of course) then the die can potentially be packed in that package.
What order they chose to bond a die to the external package pins is, frankly, no ones business but theirs. TO-92 packages are not transistor packages, they're TO-92 packages. Many many things other than transistors use them. Some devices don't even use all 3 pins, but only 2, with the third pin present but not electrically connected to anything. The exact reasons why a given pin ordering is chosen is rarely easy to deduce, but whatever it is, it's a good one. Depending on the package geometry combined with the geometry of the die itself, there probably only one or two possible configurations that won't require crossing bond wires (wire bonding machines that could handle crossing bond wires are not really available, and if they were, it would be at high cost).
If the situations is more lucky and the manufacturer has the luxury choosing from many possible configurations, then other reasons will drive their decision. Sometimes, it's more important to make the pinout be the same as similar devices, as this makes engineers happy and happy engineers (or at least, the ones you've pissed off the least) are the most likely engineers to put your part on their BOM. Other things, like low cost generic devices, all that matters is packaging cost. On a 3 pin device, the die is usually a square, and the bond pads will often be placed at or near 3 of the 4 corners. There will be a configuration that requires the shortest total length of bonding wire to package the part, and ones that don't. Bond wire is made from solid gold, so this becomes a pretty huge deal when you're spitting out 1,000,000 20 cent transistors per day. If you save 1 cent by making the pinout be ECB, then it will be ECB, because that's $10,000 of wasted gold.
So, for this reason, only the packages are standardized. Their pins will always be in a certain order, but the pinout is up to the device. It's your responsibility to read the datasheet for every part you intend to use, and by read, I mean every word, and verify the pinout. The idea that every transistor of the NPN type (which is rather arbitrary, the polarity is totally irrelevant to pin order) is not some universal truth, it is your assumption that you made, and nothing more. Some transistors have more 4 pins, others (like phototransistors) have 2. And transistors are packaged in many more packages than TO-92, and many other things besides transistors are packaged in TO-92. I can think of many reasons that one would not assume the pinouts of two totally different devices would ever be the same, and I can think of no reasons for one to assume they were.
That said, certain older transistor series do follow certain pin order schemes: 2N series transistors all use EBC pin order. BC series transistors all use CBE pin order. Except for BC635-BC640, which use CEB order, presumably because Pro Electron just wants to watch the world burn. 2SA and 2SC transistors all use CEB as well. BF series use whatever the hell they want order.
Other series has different rules, or simply don't have any.
The other big point is that many of these devices have existed for decades, long before many standards even existed. Standardized pinouts are not needed, they're a convenience and little more. What is vastly more important is that a particular part always has the exact pinout it says in the datasheet. So regardless of whatever standard you want to make, even if some universal transistor pin order standard became the norm or expected, those 6 BC transistors would still randomly have CEB pin order, because that's what those parts pinouts are. Imagine a world where 2n2222s made in the 70s have different pinouts then one made in the 80s.
Read the datasheet, watch out for small part number variations like this, and understand that certain things need flexibility more than they need convenient pinouts.
"Imagine a world where 2n2222s made in the 70s have different pinouts then one made in the 80s."
Such a world exists, today is the third time I have received a single batch of new TO92 package transistors (2sc815 in this case) - one out of 10 follows the original 1970s NEC datasheet pin configuration ECB whilst the other nine are EBC which accords with a recent datasheet from Indian manufacturer USHA.
Not seen this with 'common' transistors like BC639 / BC640 etc but definitely worth checking each individual transistor when buying stock of more obscure part numbers!!
You can literally have a mixed bag...