There is no rule that related segments of words have to be spelled with the same sequence of letters. It might seem more logical to you, but that's never been a successful argument in changing English spelling*. We also write "deception", "deceive" and "deceit", and "reception","receive", and "receipt".
In any case, the second digraph "ai" in "maintain" is not even etymological, but secondary: according to the OED, the French source word was spelled variously as "meintenir," "maintenir" and "maynteigner." The OED entry on "maintain" further states:
The English forms probably partly reflect stem variation in Old
French, where stress on the stem in parts of the paradigm gives e.g.
3rd singular present indicative -tient, 3rd singular present
subjunctive -tiegne, -teigne (although with much mixture of forms
through analogy; Middle English forms suggesting pronunciations with
close ē and with ī probably reflect respectively Anglo-Norman and
northern Old French developments of -ie- )
So the verb "maintain" either had or developed a diphthong in the stressed second syllable when it was imported into English, but the use of the specific digraph "ai" to spell this sound was arbitrary: it could just as well have been spelled "maintein", or even "maintean" with the sound of the "ea" in "great". In Middle English or Early Modern English, before our spelling became standardized, you might encounter spellings like "mainteyne" and "deceave". The standardized spellings these words ended up with are fairly arbitrary.
The second syllable of 'maintenance" is unstressed and does not have a diphthong, so it didn't need to be respelled with "ai." Despite this, though, forms like "maintaynence," "maneteinance," "manteanance" and and even "manteignance" were sometimes used in the past according to the OED, but they did not win out in the end. I don't know if these spelling variants correspond to variant pronunciations, or if they were just affected by the spelling of the related verb as with the modern non-standard variant "maintainance."
The word "maintained" is not just related; it's actually the past tense form of the verb "maintain", so it's to be expected that we use the same spelling. "Maintain" is a regular verb in English. The words "maintainer," "maintainable," and "maintainability" all relate to the verb via common suffixes that generally take the verb as the stem without altering it (we can compare "explain," "explanation," and "explainable").
*With the marginal exception of Noah Webster, but even he didn't get all that he wanted