As user77834 points out, the currently accepted answer is quite simply not correct and should not be accepted.
This question is really, unwittingly, asking two separate questions:
- Why is there a difference in the number of consonants in word pairs like attach and detach?
- Since the answer to (1) lies in etymology, what is the etymology behind attach and detach?
This is going to be quite long, I fear—in fact probably the longest answer I’ve ever typed out here—but it will also answer both questions in (much, much) more detail than other answers have done so far, so bear with me.
Why the -t- vs. -tt- discrepancy?
This is a very general pattern in word pairs borrowed from French or Italian, as well as those taken over straight from Latin or created in neo-Latin. The answer to that is to be found in Latin itself.
Latin had three different relevant preverbs: ad- ‘to, towards’; dē- ‘(down/off/away) from, opposite of, not’; and dis- ‘apart, in a different direction, not, un-’. Of these, the two first were also standalone prepositions: ad ‘to, towards’ and dē ‘(down/off/away) from’.
Already from the earliest stages of Latin (several centuries BC), ad- did something that plosives very frequently do: it assimilated to a following consonant. This basically means that the final consonant in ad- (the d) became the same as the following consonant, which created a geminate (double) consonant; so adf- became aff-, adp- became app-, adl- became all-, adt- became att-, etc. Taking a Classical Latin example, ad- + tingō was (almost) never written adtingo, but attingo.1 This explains why attach has two t’s.
As you can tell, dē- and dis- were fairly close in meaning, though they were still distinct in Classical Latin. In Late Latin and Common Romance, however, they started to get confused and merge: you ended up with a random array of dē-, dī-, des-, and dis- all muddled up. Eventually, des- ended up winning out and being the one regularly used in Pre-French and Old French (though some words still retained other forms).
Some time around the late eighth or early ninth century, a sound change occurred in Old French whereby an /s/ became reduced and finally dropped altogether between a vowel and certain consonants (basically, any consonant except /p k b ɡ s/). This means that desX- came to be pronounced something like [dehX] and later just [deX] (where X is any of the triggering consonants). So for example destenir (from Latin dis- + tenēre) became pronounced something like *dehtenir and later on just as detenir. Note that this /s/ just disappeared: unlike the /d/ in ad-, the /s/ here did not assimilate or do anything that would cause the /t/ to double.2 This explains why detach has only one t.
Etymology of attach and detach
As other answers have mentioned, attach and detach are Old French words, but they are not Latin words. None of them existed in Latin: they were formed in Old French (or rather Pre-French) by adding the preverbs discussed above to a word that had entered the Romance languages as a loan word after the Latin period.
So what was this loan word, then?
Germanic *stakan- ‘stake’
As linked to by user77834, Larousse gives only a very brief note on the etymology of attacher and détacher (translated):
Attacher:
Old French estachier ‘plug in, drive in’, from Frankish *stakka ‘post, stake’3
Détacher:
From attacher
user77834 interprets this as meaning that the French verb is derived directly from the noun (borrowed from Frankish as estaque and estache) as Old French estachier, and that this in turn directly gave later French attacher. This is a very sensible interpretation, and it does indeed appear to be what Larousse are saying.
Unfortunately, it is quite simply impossible. Sadly, Larousse do not cite their sources, so I cannot tell where they get the idea from, but Old French estachier cannot possibly yield French attacher. As we saw above, /s/ between an /ε/ and a /t/ was weakened and lost in (or before) Old French, leaving behind a now tensed /e/ and a non-geminate /t/. The outcome in later French of estachier would be †étacher, not attacher.
In order to get the actually existing word, the preverb a- (the Old French descendant of Latin ad-) must have been prefixed. Whether a- + estache would give attachier, however, is doubtful. For that to be the case (i.e., for the s to be lost and the t geminated), you would need to get ad-, with a d, right next to the t in estache at some point. Three requirements would have to be fulfilled for that to happen:
- the final /d/ of ad- would still have to be there when the word was coined;
- the prothetic vowel in estache would have to be removed so you really ended up with ad- + stache as your basis; and
- in the cluster /dst/ (which would almost certainly be assimilated to /tst/), the /s/ would have to be lost.
However, all three premises are unlikely. The final /d/ of ad- was undoubtedly gone by the time the verb was coined: it started disappearing already in Late Latin and in all the Romance languages, it only shows up at all in Italian—and only before vowels there. The prothetic vowel was added as part of an automatic process preventing any word from beginning in /st/, so it must have been added directly to the borrowed word right when it was borrowed as a simple noun, before any verbs were ever derived from it. And in the cluster /dst/ (or /tst/), it seems more likely, given how Romance languages generally simplify clusters, that the /d/, not the /s/, would be lost: compare how in Latin extinguere /ekstingʷere/, it is the first consonant, /k/, that is lost, giving Old French esteindre, Modern French éteindre. So even if you did have *adstachier, it would yield Old French †astachier, and Modern French †âtacher, neither of which exists.
Moreover, to derive détacher from attacher is not without problems, either. The Old French form destacher is attested; we know it existed as an earlier form of détacher. But as I noted above, the general form of the preverb used here in Old French was des-, particularly before vowels (even in Modern French, dés- is used before vowels, even though dé- is used elsewhere), even prothetic vowels (Latin spērāre ‘hope, expect’ gives prothesised Old French espérer ‘hope’, whence is derived a noun espoir ‘hope’; from this is derived désespoir ‘despair’, lit. ‘un-hope’). So if you add de(s)- to estache or estachier, you should get Old French †désestachier and Modern French †désétacher.
It is undisputed fact that the verbs estachier and destachier existed in Old French, and I have no doubt that at least estachier was in fact derived quite simply from estache, which was borrowed from Frankish *stakka-. But to derive attacher from estachier seems quite impossible to me, and to derive destachier/détacher from attacher/estachier equally so.
Having established this, we must seek an alternative solution.
Germanic *takkan- ‘tack, nail’
Friedrich Diez’ Etymologisches Wörterbuch der Romanischen Sprachen (1887) mentions attacher (and attaquer ‘attack’) under the group of cognates alphabetised under the Italian word tacco. Let us have a look at these cognates (excerpted, abbreviated, clarified, and translated to make it less confusing):
Nouns:
Notch, jag, offshoot, (head of) nail, tack, stud: Italian tacca, Spanish tachón, Occitan tacho, Old French tac
Patch or stain (esp. on a shoe): Old French teque, tache, Italian tecca, taccia, taccone, Spanish/Portuguese tacha
Heel (of a shoe): Italian tacco, Spanish tacón, Portuguese tacão
Verbs:
Tack/stick onto, attach: Venetian tacare, Lombard tacà, Provençal tacar, Italian attaccare, French attacher
Attack: Italian attaccare, French attaquer
Detach, take off: French détacher, Italian (di)staccare
So the base noun has three different senses: a nail or tack, a stain or patch, and the heel of a shoe. Quite different meanings, though they can all (with a bit of goodwill) be seen as basically something that is attached or stuck onto something else. A jag or a stud is quite literally tacked onto something; the heel of a shoe is an extra, solid bit that is attached to (and can fall off) a shoe; and a patch or stain is something undesirable that’s been stuck (or has stuck itself) onto something else.4
Diez speculates that the sense ‘attack’ started off as a reflexive usage, comparing Italian attaccarsi di ‘attach oneself to’, comparing it with the development in Greek of ἅπτω (haptō), which means ‘fasten, attach to’, but in the middle voice also frequently means ‘set upon, attack’. He notes also that the stem *takk- underlying these words is found in Germanic and Celtic languages as well.5
The Germanic stem found here is discussed briefly in Guus Kroonen’s Etymological Dictionary of Proto-Germanic, which is unfortunately quite new and still not available online. Most of the discussion relates to the Proto-Indo-European origins of the Proto-Germanic form, which is not relevant here, so I’ll just cite the attested forms:
*takkan- m. ‘branch’
Old Saxon tōgo, Middle Low German tagge, takke, Middle Dutch tac(ke), tooch, Dutch tak, toeg, toek, Old High German zuogo ‘branch’;
Old Danish tagge, Low German take ‘prickle (of a plant)’;
Old Swedish tagger ‘spike’; Swedish tagg ‘spine, spike’;
Norwegian tagg(e), Danish tak, tag ‘tip, jag’; Middle High German zacken (pl.) ‘jags’; German Zacke(n) ‘jag, prong’;
Middle English tak(ke) ‘clasp, nail’; English tack, tag.
If this is indeed the root underlying the word that was borrowed from Frankish, it seems the original meaning when the word was borrowed was something like ‘nail, tack, stud’, which must have been broadened (either in Frankish before the borrowing or in French after the borrowing) to meaning anything that was attached to something in the way a nail or stud is ‘attached’ or driven into the surface of the object you nail it into.
The fact that there are two variants in the Romance languages, one with initial tac- (corresponding to Old French [tak-]) and one with tach- (Old French [tatʃ-]) is interesting: it makes it likely that the word was borrowed towards the end of the period in which the sound change known as the Gallo-Romance Palatalisation (the second wave of palatalisations to affect the French language) was productive. During this period, /k/ and /ɡ/ were palatalised to /tʃ/ and /ʤ/ before the vowel /a/. It seems the word was borrowed at a time when some dialects still automatically palatalised /k/ as in *takka-, phonemically /takːa/, to /tʃ/, yielding /tatʃːa/ (which is completely identical with Italian taccia); but others had stopped doing so and could borrow /takːa/ as-is without any change necessary. Both variants apparently gained currency in French, and after sprouting a couple of derived verbs with a- and de(s)- as preverbs, they both started spreading to the neighbouring Romance languages. As a loan word that varied quite a bit both in meaning and form, it is perhaps not too unexpected that both masculine and feminine forms (as well as augmentatives in -on(e)) cropped up.
Taking this root as the basis of attach and detach makes the derivation much easier to envision:
- The preverb a- regularly geminated consonants it was prefixed to, so a- + taque/tache would straightforwardly give attaquer and attachier.
- The preverb de(s)- regularly lost its /s/ before /t/ (though it was still written) but did not geminate, so de(s)- + taquer/tacher regularly give destaquer/destachier, whence détaquer/détacher.
In the derived verbs, the basic sense of ‘nail’ seems to have been somewhat less liable to be broadened: apart from the evolution to ‘attack’, all the verbal forms in all the Romance languages are basically semantically derived straight from the base meaning: they mean to nail something to something else, or to remove the nail from something else, as it were. Attaching and detaching. The further secondary meanings to do with heels, patches, stains, etc., are not found in the verbal derivations.
So what about estachier, then?
As I said above, estachier undoubtedly did exist; but so did attachier, if we are to believe Etymonline, who says that while estachier is earlier, attachier is attested from the 11th century. (Sadly, this is not one of those cases where Etymonline is getting their information from the OED; I don’t know where they get these dates from.)
As I mentioned above, the outcome of Latin ex- ‘out of’ before a /t/ was for the /k/ to be lost, leaving /est/ (which regularly lost its /s/ later on as well). Similarly, the outcome of initial /st/ in French was for a prothetic vowel to develop, leaving also /est/. In other words, Old French est- (later ét-) could be either a compound verb consisting of es- (é-) ‘out of’ and a base beginning in /t/, or a base word that had originally begun in /st/.
In this particular case, estachier would be the latter: it meant originally ‘stake’, i.e., ‘drive in a stake’, but later on just ‘add to’ or ‘attach’. Attachier would have meant almost the exact same thing. Essentially, there were two very similar words that meant almost the same thing. One had a very clear and unambiguous preverb a- ‘into’ that fit the meaning of the verb very well; the other had no preverb, but could be understood as having a preverb e(s)- ‘out of’ that meant the exact opposite of what you’d expect, given the meaning of the word. A situation not unlike inflammable, which means the opposite of what it looks like it’s supposed to mean at first blush if you’re not familiar with its etymology. And then there was destachier, which meant what estachier looked like it was supposed to mean, but also had a very clear and logical preverb de(s)- ‘away from’.
Given this mess, it would hardly be surprising if estachier quite simply just died a quiet death. People started using the verbs that were unambiguous and unlikely to cause confusion, and the loser was ambiguous old estachier, dead and buried.
Notes
1 Later on, at some stage of Late Latin or Common Romance, the final /d/ in the standalone preposition ad was lost, and the preposition was thenceforth just a (written à in Modern French). At that point, then, the original /d/ only showed up as an actual /d/ in old verbs where the base verb began with a vowel, like adorn (from Latin ad- + ornāre ‘make ornate, deck’): in all other contexts, the /d/ had been either lost entirely or assimilated to the following consonant. From that point on, it doesn’t really make sense to say that the preverb was ad- anymore. Old French even started treating it completely like it was just a-: many of the historically geminate consonants, especially t’s, were simplified, so the Old French descendant of Latin attingere was most commonly spelt ateindre, rather than atteindre. There was quite a bit of variation, though, and doubled consonants were not uncommon, either; for the sake of simplicity, I consistently write geminates where they are etymologically or systematically to be expected, so while atachier and ataquer are more frequent spellings in actual Old French texts, I write them as attachier and attaquer here. Much later on, when French orthography started becoming standardised, they decided to approach the Latin origins of many words, and they reintroduced the geminates.
2 In Old French, they still wrote an ⟨s⟩ before a /t/, so they would have written ⟨destenir⟩. Later on, in the 15th century, all these s’es that weren’t pronounced anyway got kicked out: instead, they added accents over the previous vowel to indicate that there used to be a ⟨t⟩, which is why they now write hôtel, île, and détenir.
3 The initial e in front of the s is regular here. As early as the fifth century AD, initial /sC/ (where C is any consonant) started to fall out of favour, and words that began thus started developing prothetic vowels. This limitation that words couldn’t begin with /sC/ was still alive and kicking in Old French, and it is still very much alive in Spanish as well (think of Spanish people saying “In Espain we don’t estart estaring at people” or something like that). In Modern French and (partially) Modern Italian, though, it’s disappeared again.
4 As a side note, a similar evolution is visible in some Germanic languages. A spot in English, for example, originally meant a plot of land, and the Danish word for a spot is plet, which is etymologically the same word as English plot.
5 I’ll leave out the Celtic evidence here—suffice it to say that they all look like they too could be borrowings from Germanic languages.