"Country music" is music associated with the Eastern United States, in areas within or bordering on the Appalachian Mountains, generally south of the state of Pennsylvania. Country music is most heavily influenced by the musical culture of the ancestors of those making the music in that region: that is to say, immigrants from Scotland and Ireland.
"Western" music is "cowboy" music, associated with the culture of those states in the West of the USA (west of the Mississippi River) whose economies were, in the times before oil was discovered and mined, based heavily on the raising of cattle. Western music is most heavily influenced by the musical culture of the ancestors of those making the music: that is to say immigrants from places including Germany, Austria-Hungary, and Poland.
"Western" music includes songs and musical themes from the formerly extremely popular genre of motion pictures called the "Western". Many hit "Western" records were originally written and recorded for the soundtracks of movies, featuring famous "singing cowboy" film stars. "Country" music is not nearly as strongly associated with motion pictures.
"Western" music also has some Mexican music influences, since many Western films are period pieces set in decades surrounding the USA's war against Mexico. Vast territories switched from Mexican control and population, over to being colonized by people from the USA. Other Western films have to do with more recent times in settings along the border between Mexico and the USA, and the interaction between northern Mexicans and western citizens of the USA. There is little if any discernible presence of Mexican music in "Country" music.
During the era when "country" and "western" were distinct, approximately from the 1920s through the early 1960s, "Country" music was almost exclusively recorded and marketed out of the city of Nashville, Tennessee. "Western" music was not. It was recorded and marketed out of a much looser and decentralized group of recording centers from Texas to California.
"Country and Western" was the name of a radio format chart in the USA's Billboard Magazine from 1949 to 1962.
Billboard has always been the "Bible" for radio stations in the USA and the record labels and companies which service recordings to radio stations. Their naming the genre (the technical term in the music business is format, not genre) is what established the public's perception of the concept of "country and western".
This reinforces my earlier answer that what we refer to as musical "genres" all have their source as marketing plans for radio stations, record labels and advertisers who purchased advertisements on radio stations.
The Country Hound website has this to say about Billboard's charts:
Beginning in 1944, Country Music received its own chart, a juke box
list known as “Folk Records.” The chart was called “Hillbilly Records”
for a short period in 1947; then in 1949, it changed to “Country and
Western.” Finally, in 1962, “Hot Country Singles” replaced the
previous chart titles.
The key concept is that country music and western music were indeed distinctly different up through the 1940s and into the 1960s, but radio stations and record labels found that both kinds of music appealed to the same demographic group of listeners across the USA. That is why Billboard Magazine essentially codified the practice of radio stations combining both in their playlists to reach the same audience, and playing "country" music on radio stations in the American West and playing "western" music in the American South, alike.
If you want to listen to "western" music that is not "country" music, I recommend the "Western Swing" music of Bob Wills and his Texas Playboys, who were at their height in the 1940s. Western Swing is closer in musical style to big band jazz than it is to Appalachian country music. Western Swing utilizes the wide spectrum of jazz chord progressions and syncopated rhythms, whereas Country music has always relied on the much simpler formula of three diatonic chords and the rhythms of Scottish and Irish folk music.