Maybe I'm ignorant but I don't understand why these seemingly different countries wanted to unite into one state. They are inhabeted by different peoples who speak different languages. Why did they join in the first place?
Having studied history in Czechia, I feel reasonably qualified to answer this question, however, Czech history is not my specialization and this is my first longer contribution here, so bear with me.
Part 1
First off, let's start by examining what actually made early 20th century Czech Lands and Upper Hungary (heh) different and what made them close. After all, the last time a single united entity ruled over both Czech and Slovak lands was during the times of Great Moravia, which collapsed over a millenium before the establishment of Czechoslovakia.
Czech Lands comprised three main distinct regions that were also separate political entities joined under the Crown Of Bohemia – Bohemia, Moravia and Czech (or Austrian) Silesia. By the start of the 20century, the majority of population there were people identifying as Czechs and speaking Czech language (over 6 million). Then there were almost 3 million of Moravian and Bohemian Germans and Silesians (also people speaking Germanic dialect, though not necessarily Germans), who all had distinct identities different from Czechs, Austrians and Germans. There was also a Polish minority in Silesia and a large Jewish minority, which, however, often identified with Czechs or Germans based on their language instead, only a portion carried distinct Jewish identity. At the same time, the region of Slovakia had over 2 million Slovaks, 600 000 Hungarians and at least 100 000 Germans. These numbers eventually played a major role in decision making during the state-founding process. But let's not get ahead of ourselves now.
Prior to the reformation of the Austrian Empire into Austria-Hungary, the Kingdom of Bohemia was technically a separate entity among the Habsburg realms. What bound it together with the rest of Habsburg-ruled lands was the fact that the Austrian Archduke was repeatedly elected Bohemian King, with the title later becoming even hereditary. Thus Bohemia initially followed it's own internal development, independently from the rest of the Habsburg holdings, which, however, gradually melded together with the rest as the Habsburg followed centralization efforts (the biggest leaps were when Bohemia lost the Bohemian part of the Thirty Year's War and later on during Josephine reforms). In 1867 Bohemia became part of Cisleithania, which was an unofficial name for the teritories under direct Austrian rule when Austria-Hungary was established. All of this meant that Bohemia has been heavily shaped by its own tradition of statehood, but also German/Austrian culture and politics and Austrian administration, with German taking the prime spot as major communication language within its borders. This was distinct from the Kingdom of Hungary, which ruled over Slovakia. Hungarian language was dominant there and that was only the most visible difference. For example, the organisation of Hungarian nobility was different in Hugnary there were many petty "poor" nobles, while in Austria and Bohemia nobles were less numerous, but among the wealthiest in Europe. I don't want to delve into what caused this difference (wealth redistribution after the 30y War for example), but what is important is that this led into high capability of Bohemian land owners to invest into technological advancement. Also thanks to it's geographical position closer to the European west, from where innovations were coming, richness of natural resources (coal especially) and hospitable environment (compared to Austrian, Balcan or Slovak mountains) this led to Bohemia, Moravia and Silesia becoming the richest and most developed parts of Austria-Hungary (except for Vienna of course), whereas Slovak inhabited regions were comparably very poor end didn't enjoy any kind of prominence within Transleithania, the part of Austria-Hungary ruled by Hungary. The economic difference couldn't be more striking and from our perspective it would be highly illogical for Czechs to support unification where they would have to become the subsidizers. However, while economy played a massive role in the Czech-Slovak relations ever after the formation of Czechoslovakia, it wasn't really that important during the founding itself, because other factors came into play.
One of such factors is the basic Slavic mutual kinship. Firstly, it is important to note that Czech and Slovak national revival efforts were born roughly at the same time, by the end of the 18th century, when Czech and Slovak languages became studied and eventually codified. And right from the start they were viewed as two separate entities, though itnerconnected. There were no Slovak universities, but there were two universities in Bohemia and Moravia, so Slovak elite often studied there, not in Budapest or Vienna for example (funnily enough, Czech language was first available for study in Vienna, not Prague – it was so that Austrian officers could communicate with their Czech subordinates). This influenced their thinking heavily, and modern codified Slovak language is thus, very much like its Czech counterpart, inspired by Czech writings from the late medieval and early modern periods, and also adopted major parts of Czech ortography. Additionally, there was no clear border between Czech speaking and Slovak speaking teritories. Eastern Moravian dialects, e. g. Slováčtina is very close to cross-border Slovak dialects. However, despite the lack of proper language barrier, the hundreds of years of stable political borders between Bohemia and Hungary still prevented formation of any kind of shared cross-border identity. Yet during the period of the Spring of the nations panslavism emerged as a dominant doctrine in most Slavic regions except for Russia, which had multiple branches of thinking related to their Slavic identity. In the Austrian (Hungarian) Empire panslavism was a response of Slavic peoples to germanization and magyarization basically. It stressed mutual kinship and typically imagined Russian Empire as a benevolent paradise for all Slavic cultures, so panslavism also gave birth to rusophilia. What is important for us though is that it promoted the idea of Slavic peoples unified within a single state entity, be it some hypothetical state or the Russian Empire. And this sentiment had only died out when different Slavic nations came to experience Soviet occupation or indirect rule (and yes, Yugoslavia also had its own form of breaking fom panslavism). But at the time concerning our question panslavism is still alive and well and helps the establishment of both Czechoslovakia and Yugoslavia.
It seems foreign to us now, but the idea of "countries" didn't really come about until the enlightenment, and it wasn't until the French Revolution that they begun to become a reality (and in many ways the process wasn't completed until the end of WWII); before that, various territories were the "possessions" of various different ruling kings, bishops, princes, other monarchs, etc.
In terms of the Czech Republic and Slovakia specifically, they were both part of the Austro-Hungarian Empire, which had been built by the Habsburg family. They were a family of relative humble origins (they start getting mentioned around 1020) and were originally from Switzerland, but came to rule over the area of Austria. To severely over simplify and cut a long story short, they became a very powerful House within the Holy Roman Empire (which encompassed an area which includes modern Germany, the Netherlands, Austria, Czech Republic and Northern Italy), and managed through diplomatic means (often royal marriages) to rule over vast areas of Europe.
It was through this diplomatic maneuvering, coupled with the Ottomans advance into Europe (which saw various monarchs killed) that the Habsburgs were able to bring the territories of the Czech Republic (the Kingdom of Bohemia) and Slovakia within their sphere. When Austria was on the losing side of World War One (they were still ruled by the Habsburg family at this point), they were forced to dissolve their Empire, which saw the creation of many "nations", including Czechoslovakia.
As other answers have highlighted, the idea of these two "nations" being grouped together were because of various reasons, notably the thought that smaller nations would be too easy to be taken advantage of (larger states were better) as well as the Czechs and the Slovaks being "close enough" for the people who drew the borders in 1918, which is why we also ended up with Yugoslavia as a single nation.
The reason "Czechia" and "Slovakia" were "joined" is because they didn't exist as two separate nations/countries prior to united Czechoslovakia. It was a single state which was created during the dissolution of an empire. The people within that territory never made a decision to unite, and it was instead other powers (namely the victors of WWI) that made that decision.
I have covered a good bit of this in my reply here:
This is connected to the idea of pan-slavism, an ideology that seeks the connection of a group of or even all slavic ethnicities in one nation.
First of all, it should be noted that what a nation state is is a complicated question. It is in most if not all cases rather a more or less arbitrary feeling of shared identity than actual ethnic unity. It is surprising how relatively few people actually spoke French as their mother language in the first French national assembly, but for example Occitan, Arpitan, Breton or German. About 2% of the Italians spoke what today is known as "Italian" when Italy was founded. Or, as the Sardinian Prime Ministre Massimo d'Azeglio put it: "We have made Italy. Now we must make Italians."
That being said, it might not be that hard to believe that two west slavic ethnicities with very similar languages like the Slovaks and Czechs decide to join forces. Actually, even subsuming all Slavs in what today is the Czech Republic under the term "Czechs" is questionable. The Czech term "Čechy" means nothing but "Bohemia", thus does not include Moravia and Austrian Silesia. The Slavic people in Czechoslovakia were actually four, the Bohemians (Czechs), Moravians, Silesians and Slovaks (and even more if you count Polish and East Slavic minorities). All of them felt (and still feel to some extend) similarities between each other, and from the point of view of someone in 1918, it was hardly possible to tell in which cases the similarities were enough to form one conjoint state. The common goal to get rid of the German and Hungarian rule and - which is different to 1992! - the ongoing fear of possible revisionism played their part and overshadowed differences.
There were never definite borders between the Austro-Hungarian ethnicities. Cities had mixed populations. It was impossible to form a nation state in the idealistic way intellectuals might have wanted it to be, at least not without doing what was done after the second world war - forcefully expelling millions of people of ethnic minorities and majorities. More than 3 millions of Germans, who were the second largest ethnic group with more people than the Slovaks, and several hundreds of thousands of Hungarians lived in Czechoslovakia. Many of them had important roles in the old K.u.K. administrations and were forced out of these jobs and replaced mainly by Czechs. This caused a lot of disaffection not only within the group of the old elites but also among the Slovaks who didn't profit as much as they, from their point of view, should definitely have.