All these other answers fail to take into account the actual history of the use of "genres", or formats as they are known in the music industry.
This movement was initiated about 80 or 90 years ago in the USA, by the radio industry and the fledgeling record labels (the businesses that record, manufacture and sell phonographic discs.) The answer is all about marketing and money, and it is all charted in the history of Billboard Magazine, published weekly out of New York since 1894. The most important year or event in this story is 1936; I will explain below.
80 or 90 years ago the environment was different than it is today. Consequently, when the idea of musical genres was first delineated, it meant something different to what it means today.
The first appearance of music genres goes back to right after World War I, in the USA, when the industry of selling recorded music and marketing it to radio stations began. (At this time, radio stations were exclusively broadcasting live musicians playing in the radio studio, because there were not yet many record companies sending them records to play on the air. Furthermore one radio station would generally broadcast a wide variety of different styles of music that appealed to many different kinds of people, usually rotating the styles of music they played in blocks of several hours at a time on certain days of the week.)
Genres were created and clearly delineated by the record companies, the radio stations, and indirectly by the economic pressure from the companies who paid the radio stations to run advertisements for the products they sold.
The reason for this is that radio stations made money by selling time for advertisements. The advertisers would be more inclined to pay for time if they knew that the radio station could deliver to them a specific audience of radio listeners who would be likely to buy the product that they sold.
Here is an over-simplified example: If a company was already in the business of selling an acne-treating product that they were spending money marketing to white teenage girls (through magazines or television or billboards or specific retail drug store chains), then they wanted to find radio stations whose listeners were overwhelmingly white teenage girls. This is where they would choose to spend their radio advertising money. Radio stations quickly became more aware of this, so they began to differentiate and to change their previously wide-ranging musical broadcasts of many musical styles into very specific niches. In this example, a radio station would devote the entire airtime throughout the week to play music provided by record companies which was tailored to appeal only to white teenage girls. This means that the record companies got actively involved in combining record producers with songwriters and bands that would release a steady stream of new music that would appeal primarily to teenage white girls.
Thus the modern music industry was born. Genres were created based upon the demographics required by the companies purchasing the advertising. When record labels released newly-recorded music, they created promotional staffs that would recommend individual recordings to specific radio stations that catered to a specific genre in order to enable all the businesses involved to maximize the sale of both certain kinds of musical records and acne treatment to white teenage girls.
Billboard Magazine had been in operation since 1894, and it is still in operation. It is the USA magazine which from the earliest days of the radio and record industry reported on which records were being aired the most on radio, where, and which records were being sold the most in stores, and where. Billboard was and never has been a magazine for fans of music. Rather, it is an industry publication that helps music businesses follow trends and decide where to invest their marketing money to sell records.
Starting in 1936, Billboard magazine began organizing its reporting on the sales and airplay of specific records according to charts organized by musical genre. This was a confirmation and a continuation of a practice that had been going on for years beforehand. It goes without saying that the music industries in other nations of the world, whereever they had radio stations and record companies, followed the marketing methods being developed in the USA and adapted them to their own particular markets.
Billboard, weekly, would publish a "Pop" chart ("popular" music appealing to the most desireable and lucrative demographic for selling products through advertising, in other words young middle-and-upper-class white people in the USA), a "Race" chart (meaning the tracking of records played on radio stations that were specifically aimed at African-American listeners), a "Country" chart, a "Jazz" chart, and others. As the years progressed, the name and number and focus of the charts would shift.
It was radio DJs and Billboard magazine editors and record company executives who actually created and named specific genres, using terms like "Rock and Roll", "Country" (which originally was called "Hillbilly") and "R&B" (which originally stood for "Rhythm and Blues" and before that was called "Race Records"). These "genres" were certainly not created and defined by musicians themselves. It was a giant feedback loop, which propagated ever-more-specific genres. The large national corporations who purchased the advertising time and marketed their products through the advertising certainly participated.
The term used within the USA music business to describe the "genre" of music played on a particular radio station is the term format. (Link to Wikipedia article) Check out this Wikipedia article and you will see that the different kinds of formats listed correspond more or less with what music fans refer to as genres, taking into account that formats and genres are always changing in a fluid fashion as time goes by. Over the decades the popular concept of "genre" has really always been about radio formats and changes in marketing business plans for radio stations, and this has been reflected in the charts published in Billboard magazine.
It is important to understand that individual musicians and whole bands who got into the music industry were steered by the record companies and their producers into creating specific kinds of recorded music that fit clearly into specific genres, for the purpose of maximizing the efficiency of marketing and sales. If a given musician or band ever wanted to change their "genre" or even to record different songs from different "genres" on the same record album, the record company tended strongly to prohibit this, because such an album could not be effectively marketed through existing marketing channels. Musical compositions became known as "product" because recordings were sold as physical items in stores, marketed through radio, and not as "art" or "music" anymore.
The problem with the idea of "genres" is that it caught the public's imagination. The public, along with the music critics in the press, seemed to enjoy the idea of "I'm a country music fan" or "I'm an R&B fan" and defining themselves thusly. I remember in the 1970s when country music fans would wear T-shirts that said, "If it ain't country, you can kiss my ass", meaning that they would only listen to music which the radio stations and record labels, and by extension the advertisers, defined as "country". For many decades, people became accustomed to only being willing to listen to music which was marketed within the specific "genre" that the fans had identified as the one they preferred.
Now things are very different today. Now that we have the Internet and we can experience and listen to a great variety of music, we no longer depend so heavily upon the ways in which businesses like radio stations, record companies and corporations who market to us define the genres.
But the result has been ever-more-increasingly fine "genres" anyway. For example, take the rock music fan who doesn't think in terms of rock music. He doesn't think in terms of liking hard rock. He doesn't think in terms of heavy metal. He prefers to assert that he likes only symphonic death metal, and "death to false metal." Or somebody will not acknowledge that he likes music made by African-Americans, but rather that he likes a specific sub-genre of hip-hop. Or somebody who doesn't think in terms of liking dance music, but rather identifies with a specific sub-genre of EDM or dubstep or acid house or whatever all those genre terms are these days.
The idea of musical genres was created and carefully crafted by businesspeople to maximize the sale of records, but also products like acne cream to teenage girls.