Why Bach instead of one of his contemporaries?
J.-S. Bach was indeed recognized as a master even during his late life (famously, he went to visit king Frederick the Great of Prussia), despite his style being by then out of fashion, and even more soon after his death: despite being considered very old-fashioned during the “galant” era (the famous quip by Mozart about Bach being the master actually refers to his son Carl Phillip Emmanuel), at least some of his works were used as teaching material without interruption (the Inventions & Sinfonias and the Well-Tempered Clavier), and by about 1800 his reputation as the “most important” composer was solidifying. Beethoven and Mozart in their late lives were quite influenced by Bach, and slightly later Mendelssohn was hugely influential in rediscovering and saving some of his works (he conducted the rediscovery of the Matthew-Passion in 1829).
As for the reasons of this particular position of J.-S. Bach, I would say that they are twofold — some of them are due to his particular style, while other ones are more objective.
The stylistic reasons are due in part to the position of J.-S. Bach at the closing of a more “experimental” time period of Baroque music and at the beginning of the Classical period, where music generally followed a quite rigid set of conventions (e.g. equal temperament, key signatures, tonic-dominant relations, major and minor modes, march of fifths etc.). Since Bach was one of the first to write using these conventions he is considered as a bit of a rule-maker (although other composers such as Corelli (for the march of fifths) or, earlier, Palestrina (for counterpoint) certainly played a part in defining these “rules”). The time around the death of Bach is also when most of the standard lexicon for music was definitely codified; e.g. Jean-Philippe Rameau coined the words for “tonic” and ”dominant”, and it was also the time when cadences started to be interpreted in this way instead of as a set of four independent voices (with all possible permutations, etc). as they were in the 16th century. (Interestingly enough, this is quite parallel to the development of mathematics: in the 16th century equations were usually written only in positive numbers, by shifting negative quantities to the other side of the equality, which produced a huge number of synonymous formulas for e.g. solving equations, and the simplification was done at the time of Euler & Co.)
Another stylistic reason for the importance of Bach is that a large part of his music is extremely intellectual (e.g. look at the permutation fugue in the organ Passacaglia, or how the Cantus firmus is used in various cantatas, how he manages to include the full range of the four-octave keyboard in most preludes and fugues in the WTC, and I won't even say a thing about the Art of the Fugue or the canon cancrizans), which is enough to make it appealing to most later composers. As a proof of this fact, see how much he was copied: a lot of composers tried to imitate at least the form of his works by writing sets of preludes and/or fugues, from Reicha and Chopin to Chostakovich. (And indeed, the Well-Tempered Clavier is probably his most influential work by far. J.-S. Bach did not invent the principle of such a collection — Fischer did that a few years earlier with Ariadne musica — but he was the first one to succeed in incorportating all 24 keys, where Fischer had only 20 of them).
As for the objective advantages, one that certainly made J.-S. Bach important is the length of his career. While not as many works survive as Telemann's, he wrote quite a huge number of pieces in very wide variety of genres (from religious piece to dance suites and abstract music; every genre except opera, although the Coffee cantata is a quasi-opera) and instrumentations (from a solo flute or cello to an orchestra with a double choir). In this respect, the work accomplished by his wife Anna Magdalena to collect and organize the scores for as many pieces as possible played a huge part!
Finally, one of the best reasons why every other composer considered Bach as their teacher is because he was just that — a teacher. And it shows in his music. It is even explicitly written e.g. in the introduction to the Inventions and Sinfonias:
Forthright instruction, wherewith lovers of the clavier, especially those desirous of learning, are shown in a clear way not only 1) to learn to play two voices clearly, but also after further progress 2) to deal correctly and well with three obbligato parts, moreover at the same time to obtain not only good ideas, but also to carry them out well, but most of all to achieve a cantabile style of playing, and thereby to acquire a strong foretaste of composition.
In this respect, some of his work can even be understood as a “how to compose like J.-S. Bach for dummies” manual, by chaining them in the correct order: first the 4-voice chorale settings (there are about 400 of them, and even today they are one of the main instruments in the beginner's toolbox for harmony!), then the 2-voice small preludes, 2-voice inventions, 3-voice sinfonias for basic counterpoint, Orgelbüchlein for ornamentation, dance suites for form, etc. up to well-tempered clavier and Art of the fugue.