I've Googled this question before, and it keeps giving me answers about Anschluss in the 1900's, but what I want to know is why Germany and Austria have been separate countries/"confederations" for hundreds of years despite being ethnic Germans who speak similar kinds of German and live in mainland Central Euroupe.
I'm a Swiss American so I know a bit about Swiss history, admittedly probably not as much as an actual person from Switzerland.
The German speaking cantons of Switzerland joined their Confederacy of their own volition in the middle ages one at a time, before that they were semi independent territories of the HRE (their were alot of different little federations in the giant federation that was the HRE). Some were religious territories ruled by a high ranking catholic official (Bishops and such) others were some noble families territory (barons, ritters, and grafs) some were independent "free" cities ran by Burghers (I think Berne and Zurich) they formed their Confederacy for self defense against outside threats and to monopolize on the trade through the Alps (later to monopolize the European need for mercenaries). The first three Cantons of Switzerland were Uri, Schwyz, and Unterwalden (all german speaking, each one was rural aswell). It should be noted that the people in the Alps had more in common with their immediate neighbors (no matter what langauge or dialect they spoke) than with the people in the lowlands (even if they spoke a related dialect of the same language).
The main reason the old semi independent Swiss Confederacy became fully independent from the HRE, is the Habsburgs coming to power. Everyone who knows anything about medieval Switzerland knows the medieval Swiss mindset basically comes down to one motto "Fuck the Habsburgs".
The reason Austria is not a part of Germany is simple, Austria lost to Prussia in the race to make Germany, and after WW2 they just aren't legally allowed to confederate with eachother. They also just don't want too, they have been separated for quite sometime.
It should be noted that modern Germany is quite "artificial". In the sense that before their was a German nation state, Germans were a wide variety of related peoples. They spoke widely differing dalects and practiced different lifestyles depending on the region.
They were not separate for hundreds of years- they have only been separate for about 150 (with interruptions). For nearly 850 years before that, Austria and the states which would become Germany in 1871 were part of the HRE, or Holy Roman Empire (c.962-1806), along with what was later to become the Swiss confederacy for c.550 years (c.962-1499). This was a loose group of states and free cities across the remains of Charlemagne's European Empire originally ruled by one of his descendants.
For much of the HRE's existence, Austria was the dominant state (it headed the empire for over 300 years from 1440-1740) which other rulers resented. It was also very Catholic. The Swiss free cities resisted the Austrians and began to exercise more autonomy from 1499 onwards, but it was only once the Protestant territories of the Hapsburgs (the Netherlands and Switzerland) became involved in a 30 year war involving them, the French and a few other Protestant powers against the Hapsburgs that they formally left the HRE.
After the fall of Austria in 1806 to Napoleon, the HRE was formally dissolved and replaced with a German Confederation of 37 states. The German states were in a state of flux, with the axis between the old power Austria and the rising power Prussia becoming less stable. Austria had been shown to be no longer unbeatable, and increasingly Prussia, the second largest German state saw its chance to dominate the other German states. Through clever moves and war, Bismarck, the Chancellor and effective leader of Prussia, managed to unite Germany under Prussian leadership while beating the Austrians in 1866 in a short war. As a result, Prussia was firmly in control of the remaining German states until WWII. The Prussians did not annex Austria because if they had done so, the French or/ and the Russians would have stepped in (it has long been a principle in European politics not to allow one power to dominate the continent). Likewise they didn't touch Switzerland as it was not identified as a German state and might have drawn the French in.
Just before WWII, Germany annexed Austria, but again the principle of no one power dominating the continent meant after the war the victors broke this union and divided both Germany and Austria amongst themselves into quarters, separating them again. Switzerland was not annexed during the war- its mountain locations would make an invasion costly, and the reward in terms of people and territory was limited. Many years later after suspicion of Germans had lessened and the Cold War had ended, Austria joined the EU. Today, Germany, Austria and the Swiss Germans have many common laws via the EU, and a common language, but not a single state.