I haven't learnt a lot on German Unification but it would make sense to me, particularly considering their shared Catholicism, that Bavaria would be much more likely to join Austria than largely Protestant Germany. Was it just a hang-over from the Holy Roman Empire which Bavaria had been a part of or were there more political reasons for it?
My understanding is that during Otto vonBismark's attempt to unify all of the Germanic states (ie.Bavaria, Wurttemburg, Hanover, etc.) Prussia and Austria grew apart because each state felt that they should speak for the greater good of Germany. Eventually leading to the Austro-Prussian War in 1866, during which all of Austria's allies (Bavaria was one of them) either quit on her or did little to aid her cause.
Through this victory, Prussia was able to annex several states such as Hanover, Hesse-Kassel, and Nassau (not the city in the Bahamas). This was known as the Northern German Confederation. Seeing this, Austria decided to team up with Hungary, creating Austria-Hungary.
Fast forward a few years and Prussia is at war with France. Ending theis war was the Treaty of Versailles 1871. This treaty stated that All southern Germanic states(ie. Bavaria) were to become a unified Germany. Austria was given a chance to join the empire but they were unwilling to relinquish territory/Hungary for this new empire, and because of this, Prussia's Friedrich Wilhelm IV took control of the New German Empire. So I suppose Bavaria just wanted to be part of something larger, maybe for monetary reasons, protection, or power.
Sources:
Introducing Austria: A short history by Lonnie Johnson
The Franco-Prussian War: the German invasion of France, 1870–1871 by Michael Howard
TL;DR More political reasons.
Bavaria was forced, by a military invasion in 1866 (see also https://de.wikipedia.org/wiki/Schlacht_bei_Kissingen - alas no english version).
In 1870, after a common military success, our Bavarian king, who was not in favor of loosing the Bavarian autonomy, agreed at last to join this "Kaiser"-Reich. Later people said that he preferred to build castles over a war with Prussia. He even boycotted the founding ceremony in Versailles and sent his little brother instead. On the other hand many (at the time viewed as) progressive people, also in Bavaria wanted the unification. While others wanted to defend the Main-line. The Bavarian paliament of the time was a lot anti-king and pro-unification.
I set "Kaiser" and "Reich" in quotes, because it attempted to recreate (fake) the real HRR for German speaking people, but it failed miserably, omitting at least two big German speaking nations (Switzerland and Austria). And of course the countries not speaking German (most of Italy was in the HRR). Also Prussia, a baltic nation which was never in the HRR, became the leading force with Berlin as the capital. Since this time prussians in Bavaria were seen like a foreign occupation for many. Prussian officers became boss in the capital Munich. After that the now bigger "Reich" led Bavaria into 2 devastating wars with virtually the rest of the world.
A similar "faked" Reich or Kaiser was constructed by the Habsburger after 1809. Up to this date the Habsburgers had been Kaiser of the HRR for many years. After Napoleon forced HRRs dissolution, they quickly made a new "Kaiser" by uniting now with Hungary (Napoleon also wanted to recreate the Kaiser-Reich, but including France - like it was before - and himself the Kaiser).
It's not (only) the catholicism that links Bavaria to Austria. Most of it beeing the language. As a Bavarian I can understand the language of Tirol (now Austria and Italy) better than northern derivatives. Also historically Bavaria extended to the Mediterraneum until 788, so it was basically one nation with Austria. edit: Also Austria, Bavaria (without Naoleons addons) and Switzerland were simultaneously part of the Roman empire for 400 years. And before that Celtic - very much like France or even England where just the Roman occupation occured ~60 years earlier. edit2: and for England ~60 years later
So, I'd say mostly by military force.