Summarizing everything
tl;dr
The drive before the twist will be drive B while the one on the end will be A. This way, there is no need to "configure" the drives which drive (A or B) are they going to be and what they should listen to. They can be configured identically and the twist will swap the controlling input for them.
Or quoting sawdust, from this comment:
The cable twist allows both floppy drives to be configured identically (for drive selection) when installed (for manufacturing convenience), yet operationally, can be uniquely selected as either the first drive or the second drive based on cable position.
Pins and cabling
The twisted pins are from pin 10 to pin 16.
Explanation
Without the twist, we have to configure the drives and set them to be drive A for one and B for the other, because when the motherboard selects for example drive A, both drives would receive the select signal if they are both configured as a drive A. To avoid this, we should setup them by jumpers or by hard-wiring their role so there would be a drive set to be drive A that would listen to signals on the select A wire, while the other drive would be drive B that would listen to signals in select B.
This is totally doable, but we don't want to mess with the setting of the drives, just want to throw them into the PC case and plug in the cables.
Let's say both drives are hard-wired to be drive B. Now we don't have to setup them, but they both listened to the select B signal, while the motherboard would still want to send a signal to select A to select drive A. Here comes the twist! After the first drive, we twist the select cables so the drive A (that is still a hard-wired drive B) will listen to the select A controls, because we connected the select A pin to its select B pin (the only pin it listens to).
Now the drive before the twist will work as a drive B listening to select B signals, while the drive after the twist will work as drive A listening to select A signals. They're both hard-wired drive Bs that listen to their select B pin, but for one drive we connected the select A pin to its select B so the motherboard can control it through the select A bus.
With hobbs's words here:
The pins are in fact "Drive Select A", "Drive Select B", "Motor Enable A", and "Motor Enable B". The twist swaps Drive Select A<->B (pins 14 and 12, respectively) and Motor Enable A<->B (pins 10 and 16, respectively). All are outputs on the floppy controller and inputs on the drives.
and here:
The rest of the pins (read and write data, stepper motor control, head select, etc.) are bussed in the normal fashion, which is why the drive select pins are so critical. A drive has to ignore all input and produce no output when it's not selected
While hard-wired drives are usually a drive B, there is the chance to be a drive A as said by Tonny here:
I once had a whole afternoon of entertainment trying to figure out why a drive which came from a working system wouldn't work in another computer... It turned out to be hardwired for A and the original computer used a normal cable, but had the signals twisted on the motherboard itself!
Also, please note what Michael Hampton wrote here:
Certain non-PC-compatible systems (like the Radio Shack Color Computer) did actually use floppies without the cable twist, but required manually setting the jumpers, and could indeed use four drives at once. While this hack allows for the end user to not have to mess with jumpers, it also restricts the system to two floppy drives.