I was always curious why classical composers use names like this Étude in E-flat minor (Frédéric_Chopin) or Missa in G major (Johann Sebastian Bach). Is this from scales of this songs? Weren't they blocked to ever use this scale again? Why didn't they create unique titles?
Many classical composers frequently used this method that you stated. Bach wrote over 1120 pieces. Naming 1120 pieces, each with a unique name can be hard. Some were named for where they were performed e.g. the Brandenburg Concertos. It was also common for a composer to number his pieces of the same format. Eine Kleine Nachtmusik is also known as Serenade No. 13 for strings in G Major. The most common technique, however, was to name after the musical form and its key. Beethoven composed a Bagatelle in C minor. He then titled this piece Bagatelle in C minor. His well known Fur Elise is also referred to as Bagatelle No. 25 in A minor.
Using a key did not prohibit a composer from using that key again (there are only thirty keys). Using a key did not prohibit them from using the same key on a work with the same form either. Bach wrote over thirty Prelude and Fugues. Four of these were Prelude and Fugue in A minor. They are now differentiated by their own BWV catalog numbers (assigned in 1950). Many pieces did have unique titles, but with the amounts of pieces the composers composed, unique titles were difficult to come up with. Also, most pieces had no lyrics. It is much easier to come up with a title when there are lyrics. So, they turned to this technique. It was used frequently during the Common Practice Period.
Opus numbers are also used to number pieces. They only number published pieces though. Not all pieces a composer wrote would be published. Some works published posthumously are also given Opus numbers.
Opus numbers are different from the catalogue numbers I mentioned before. Some composers have multiple catalogues of their works which can be confusing.
These are all good answers, but I'd just add a historical note. Composers before the time of, say Beethoven, composers like Bach and Mozart, often did not publish all or even most of their musical works, either because no one wanted them, or because they wanted to keep the pieces for their own use. The vast majority of Bach's music was not published in his lifetime, so there was little need to "name" the compositions. Often the names we use (Brandenburg concerto; Jupiter Symphony) were added later, as nicknames.
Neither Bach nor Mozart left any definitive catalog of works (Mozart wrote up a list from memory late in life, as I recall, but he got things wrong). It was left to musicians and musicologists to find all the manuscripts, try to figure out what order they came in, give them some numbering system, and then publish them in large collected works editions. Most of this editorial work did not even start until well after the composers were gone, at the end of the 19th century.
(This is where the letters and numbers after many 18th-ct. works come from: they are catalog numbers, like Mozart's K numbers, K being Koechel, the editor of the first Mozart edition, or J.S. Bach's BWV numbers [standing for Bach Werk Verzeichnis, or Bach Work Catalog in German]. Even Beethoven left a bunch of works unpublished at his death; they are in his collected edition with W.o.O numbers, standing for "Werke ohne Opuszahl" ["works without opus number"].)
So, in his lifetime, Bach, like most composers, never needed to give distinctive names to most of his works, because most of them were never intended to be used by anyone but him. The full numbering of, say, Haydn symphonies was a real mess, because for most of his life, Haydn just wrote symphony after symphony for his patron(s), who owned them as absolutely as they owned paintings or sculptures they commissioned. When he got famous, some of "his" symphonies became well-known and published, but even those were likely to have been in short numbered sets of, say, six or twelve, like the so-called Paris (82-87) and London (92-104) symphonies. (I used to play four-hand arrangements of Haydn's late symphonies where the numbering started at 92, as if those were the only ones that mattered!) And, when I was a kid, there were supposed to be 104 Haydn symphonies; now we think he wrote at least 107, but do we renumber all the later ones to accommodate the very early ones we found? Heck no!
Even more recent composers run into this problem. Bruckner wrote and published nine symphonies. But then, after his death, they found an early trial-run symphony that he wrote but never published, so they decided to call it Symphony No. 0 ("Die Nullte"). Then they found another one, so they called it (not Symphony No. -1, that would have been awesome), but Symphony No. 00.
And so it goes...
By "Classical", I assume you mean "not pop music" rather than the historical Classical Period specifically. The examples you gave weren't actually Classical composers (J.S. Bach was a Baroque composer; Chopin was Romantic).
In Bach's case, his music was always very functional - it almost always served a purpose. As such, it made sense to give functional names to his works. Categorising pieces into a musical form and a key (Toccata & Fugue in D Minor) made much more sense than subjective sentimental titles like "Scary Atmosphere for a Haunted House", for example.
Another reason was the sheer volume of works that these composers produced (Bach wrote over 1,100; Chopin a 'mere' 230 that we know of). Naming them all with something poetic would have been a task in itself!
In addition, the majority of these functionally-named works were instrumental - if you look at their choral/vocal pieces, they are more likely to have alternative names, simply because having words in them means a title is easy to extract.
Chopin wrote few songs, but one example is Smutna Rzeka (The Sad River) - no mention of musical form or key there.
Similarly, Bach wrote many religious songs (Cantatas) without reference to form or key, e.g. Ach wie flüchtig, ach wie nichtig (Ah how fleeting, ah how futile).
Compare these with modern music which is now predominantly vocal, i.e. pop songs - and you can see why we don't really need to name things with reference to form and key any more. The title is suggested by the lyrical content.
So as ubiquitous as Justin Beiber may seem, he has a long way to go before he even equals a quarter of Chopin's output and hence he can still name his composition "Boyfriend" rather than "R&B Hip-Hop song in B♭minor".
The purpose of adding so much information is to insure the reader knows which work is in question. To make up a case, say we start with a Chopin Waltz. We could name the key - Eb, for example - but there could be more than one Waltz in Eb. To narrow it down, we might provide an opus number (when it was composed) or a date in the case of some more recent composers. What if there is more than one Waltz in that key and with that same opus number? We would need to know the number in the opus. This isn't a Chopin work but let's pursue the business to the end for an imaginary one - Chopin (composer) Waltz (title) in Eb (key) Opus 50 (order of when it was submitted for publication) No. 3 (to be specific), so Chopin's Waltz in Eb, Op. 50 No. 3. That's almost always enough information. If we need to be even more specific than that, perhaps the tempo could be sited, but I've never seen that occur.
Even in the context of rock and roll, coming up with names is hard. Gems like "A Simple Desultory Philippic" don't just grow on trees. You have to dig them up!
There is some trend toward abandoning "names" in electronic music, where sometimes just the BPM will suffice. And of course, sound effects recordings.
It'd be nice to get away with calling things "double-boogie 100 #3", "minor descending-bass rag 120 #2", "rock waltz #437".
My guess is that a musical piece was just that, and did not need to be connected with other aspects as it is today.
Music expresses very often non-musical feelings nowadays, for examples through titles (but not only). I don't think it was the case then, not to the same extent.
We give very much importance to the name of a piece today, but there was no need to choose a name then, since that was not as important.
I suppose that this changed when composers started to consistently express something else than just the music, through the music. Debussy's symphonic poems come to mind, but it surely started long before him.
A simple answer is: because it works; it helps to reduce the number of matching pieces and there is a good chance, that it is unique then. For example Schubert: if you select "c major", just two symphonies remain, therefore a "little" or "great" is usually added. One easily recognises, that this naming is only possible at later times. The names came seldom from the composer itself, but were either invented later for easy classification or - more likely - by the publisher of the score, to have something like a "marketing brand" (often even against the will of the composer). Further sources are customer ordering or artist playing the piece (Goldberg-Variations, Diabellis variations contest), the town, where the first performance took place (Haydns London symphonies are a handful, so additional characteristics were needed, like "the clock" due to a rhythmic pattern in a middle movement). One has to remember, that in the days before radio and grammophone composers were simple responsible for producing music for banquets. I can imagine, that they were happy to have a piece finished and the score copied in time and did not bother for inventing a name.