Bavaria and Austria never have been a united country. The region, where people spoke German dialects, and which is today covered roughly by the countries Germany, Austria, Switzerland and Liechtenstein was hundreds of different countries in the past. They united to something similar to todays European Union, but only for mainly German speaking countries, and this union of countries was the Holy Roman Empire of the German Nation, but also some non-German speaking regions like parts of northern Italy and Slovenia belonged to it.
Germany as a country did not exist and Austria was a small country in those days, covering the region of the two today's Austrian provinces Upper-Austria and Lower-Austria. But for example even Salzburg or Styria did not belong to Austria. The famous composer Wolfgang Amadeus Mozart was not an Austrian citizen. His nationality was Salzburgian, and he never changed that nationality. Salzburg became part of Austria only many years after Mozarts death.
Later Austria grew to a huge nation. Not only Salzburg and Styria, but also Tyrol and Carinthia became part of Austria, whereas about 1/3 of Styria was not German speaking, but Slovenian (and this part is today a big region in Slovenia). But also Hungaria, the regions that today belong to the check republic, and many more areas were part of Austria. Even parts of the Ukraine belonged to Austria, including the Crimea peninsula. The Habsburgian monarchy had emperors in Spain and even in Mexico for a few years.
Austria lost all non-German speaking regions at the end of world war one, in 1919, and it even lost some German speaking regions (South Tyrol now belongs to Italy). But it kept some small Slovenian speaking regions in the south (in Carinthia), and when former German-West-Hungaria became the ninth Austrian province Burgenland in 1921, also some Croatian speaking regions became part of Austria.
And when all this happened, Bavaria was never a part of Austria, and Austria was never a part of Bavaria. They were always two separated political regions, only both part of a bigger union together with half of Europe, like Austria and Germany are now as part of the EU.
And, as Janka said correctly in his answer: About half of the people living in Bavaria are not Bavarian native speakers. They speak Franconian and Swabian dialects.