What happened was that, prior to 1815 at Vienna, Prussia was a second rate power. By that I mean they were not on the "tier" of France or Britain or Austria but still had their weight to throw around as a regional power; they were not ignored but were not leading European politics. You can see from this map here how truly rapidly they expanded during and after the reign of Frederick the Great. They certainly were not aching for land and, by the time of the Napoleonic Wars rise, were (in accordance with Russia) partitioning and cutting Poland apart in a land grab. They were, in other words, on the cusp of being a "great power" on the likes of Austria, Britain, and France in terms of global influence (they even beat Austria in a war!) but weren't quite there yet before Napoleon started throwing a wrench in things.
So then the Napoleonic Wars happen and it makes matters even worse for basically all of Germany. The Holy Roman Empire, the legal framework which protected literally hundreds of sovereign states from being gobbled up and fighting between each other, was torn apart by Napoleon permanently. The German states in the West were organized into the Confederation of the Rhine along with hundreds of states disappearing overnight and being mediatized (integrated/simplified) into bordering, more centralized states. Prussia is defeated at Jena-Austerdedt and would lose a significant swathe of her territory (orange is all they would keep) and the war would rage on and blah blah blah filler that isn't really important in this kind of overview.
The Napoleonic Wars end and we are at the Congress of Vienna where the Great Powers, notably Britain though, want to keep what is called the 'balance of power' in continental Europe; not allowing one power to dominate the continent. For hundreds of years that dominating power was the Hapsburg Empire, the Austrians, and to mitigate this along with rewarding them for their years of contribution to the war efforts, Prussia is given a sizable reimbursement of land. She would go from, overnight, a second rate power on the cusp of victory to a war torn and battered power without a hope or reason to regain vigor to one of the Great Powers of the world. Now Germany was divided; Prussia dominated the North and Austria, in general, the Southern Catholics.
However you see something there called the "German Confederation"; a sort of replacement Holy Roman Empire that managed to find a way to be even more useless. However it did have its uses for Prussia, notably the Zollverein; an economic customs union shared between all member states to increase mutual economic prosperity between all Germans. This served a dual purpose:
It gradually sidelined Austrian influence as the Prussians dominated Germanic industry; Prussia controlled 90% of the production of mining and metallurgical industries across all of Germany along with 50% of the textile production along with, even further, employing 2/3rds of all factory workers in Germany.
It created economic unity within Germany which facilitated ideas of further centralization into a state
As things progressed the 1848 revolutions rocked the foundation of the German Confederation to its core and then, by 1866, it was ripe for destruction in the form of Prussia dominating Austria in the Seven Weeks War and would form the North German Confederation while also removing Bavaria, Wurttemberg, Hesse-Darmsdadt and friends from Austrian influence. Here is the map of the member states. Members had privileges including the right of free movement within the NGF, a common passport and postal system, Prussia's military laws and doctrine replacing all member states, and equal religious rights. At this point the NGF is, for all intents and purposes, as close to a unified state as one can get with its submembers maintaining a degree of sovereignty.
Prussia was now the indisupted dominant actor. The infamous Concert of Europe has, at this point, also indisputably broken down and the power balance is in whack and here we get to see Bismark's masterful diplomacy in action: The Concert was broken in 1866 and Russia threatened to intervene. What did Bismark do? Outside interference, he threatened, would compel Prussia to "unleash the full national strength of Germany and the bordering countries [in revolution]." As in, when someone tried to intervene, he used the threat of facilitating another 1848-esque liberal revolution wherever he was opposed, in this case famously, Russia. His famous phrase being "If there is to be revolution, we would rather make it than suffer it." The Tsar backed out as no one would support him and feared for his own stability.
Yet one little bit remains....Southern Germany. Those four little precarious states, Bavaria, Baden, Wurttemberg, and Hessen, were surrounded on all sides by Great Powers; Austria, Prussia, and France. Austria would want to reverse 1866 and get them under her wing, Prussia wanted them for unification, and France wanted a buffer state of at least semi-likeminded Germans against Prussia. Bismark would have to bring these states under heel while also simultaneously not goading intervention from the other Great Powers who wanted to maintain stability in Europe; this was best done, as you might imagine, by beating the biggest Great Power who wanted to make sure a unified Germany never became a thing; France. Think back to what Bismark said but even greater: He wouldn't be the victim of intervention, he would intervene against the interveners before they could and, through victory, make his actions permanent.
They were far more liberal in the South and were, most importantly, Catholic compared to the Protestant North. The South was also the heart of what you may be familiar with as Ultramontanism, political Catholicism. Bismark, to the say least, despised this calling it "a hypocritical idolatrous papism full of hate and cunning." This political catholicism would come hardest after 1866 precisely because of the Southern opposition to union with the North along with Catholic reistance to the attempts of "liberal regimes to promote secular education and civil marriage" (Carr, 166). The absolutely brutal treatment of the Southern states in 1866 just furthered their solidarity against union with the North; including but not limited to the disregard of dynastic rights and minimal concession to liberal opinion in the new Confederate Constitution.
To loop back around to 1866 Bismark, quite tactically, dealt with Austria and the Southern States separately at the Peace of Prague in 1866. He dealt with Austria first, dealing them a light hand intentionally to keep the rest of Europe off his back, but then went all out against the Southern states afterwards against whom he was intentionally onerous. In addition to military alliances he demanded large indemnities and territorial cessions from Wurttemberg, Bavaria, and Hesse-Darmstadt (but not Baden who was favorably disposed to Prussia!).
It worked just as planned; in return for the reduction of indemnity and the abandonment of most of the territorial demands Wurttemberg and Baden agreed to willing military alliances. Bavaria desperately turned to France but Napoleon III was sated: Prussia was giving France some land (Venetia, to be precise) to keep them distracted; why would Napoleon III intervene with war when he was already getting cessions from those he would go to war with? Bavaria had no one to turn to and was forced to accede to Prussian request. All 3 states + Prussia agreed in offensive-defensive treaties guaranteeing each others territory and, in event of war, to cede their railway systems and armies for the King of Prussia's command. As William Carr puts it masterfully:
"The first bridge had been built across the Main, the fruit of military victory and French rapacity, the southern isolation and threat of Draconian peace."
This was answered so well already all I'm going to say it that my favorite quote with regards to Prussia is " Prussia is not a nation with an army; its an army with a nation."