For what it matters, Germany wasn't as unified as France or Spain.
It was more unified at least until the XIIIth century, thanks to imperial structures and prestige, and didn't really knew the important feudal desintegration that happened in France (at the exception of atlantic principalties), Burgundy (which is admittedly an extreme case, tied up with the particularily important desintegration happening in Aquitaine) and Italy (especially after the death of Matilda of Tuscany).
It didn't either knew the several divisions of Christian Spain underwent until the XIIth.
It's not even a case of not catching up with the growing bureaucratization and unifying trends, as a lot of these originated from Imperial Italy and Germany.
So, what got wrong? At which point Germany underwent changes that make it unable to undergo the same changes that in France?
Well, it's mostly due to a whole array of political and institutional reasons, which separatly were manageable (and generally were managed) but taken together, much less so.
First, it's the imperial character of medieval Germany and Italy : these existed as cultural, political and proto-national ensemble, but the overlording body was the Empire. It led the various strong dynasties to live up to their quasi-universal pretensions if they wanted to legitimize their rule. It led to clashes with Papacy, itself quite bound on universal hegemony, and the various city-states, duchies, etc. that could benefit from the big extension of the Empire (HREmperors could be forced to end a revolt in Italy, mere years after having dealt with Germany) and from pontifical support (HRE, too far from God, too close to the pontiff).
And there's the kicker : while other kings and great nobles didn't THAT feel threatened trough excommunication (they still did a bit, sometimes), HREmperors did. They needed the pontifical aquescit to legitimize their rule as emperors, and excommunication didn't just meant for them that Rome was very, very, disappointed. It meant they were theoritically deprived to their right to rule as emperors, which litterally everyone could use as a pretext to revolt : the strong papacy Ottonian supported at first in order to legitimize their imperial claims became more and more of an hindrance.
It doesn't help that Germany itself harboured, at first, relatively unified feudal entities : where the Kings of France eventually had to deal with neighboring entities that looked like confetti on a map (usually pledging alliegance to several overlords because why the fuck not) and could benefit from this as any overlord as Plantagenets would see their rule itself build on political moving sands (half of the rebellions against Henry II can be explained as such); the HREmperors had to deal with big, self-important and rivaling aristocracy.
When Capetians were perfectly able to build-up their power in north France (the weakness of early Capetian is generally grossly exagerated tough : in spite of their relatively small holdings, it was still more unified than their immediate neighbors, was set on a prosperous region, and they beneficied a lot from the suzerainty link over great nobles), Ottonians and Salians had to go trough an higher road than "Well, today I'm going to war against a vassal then change sides in order to get a territory no greater than a sous-préfecture".
That alone, tough, wouldn't have been that handicapping if HRE didn't suffered dynastic instability in the XIIth. Early French or German kingship became somehow elective by the Xth century (altough it's more of a case of dynastic popularity contest among potentes), but in both of these regions, it quickly became ceremonial elections only by the end of the century (mostly trough the use of co-rulership in France, and coronation as king of Romans for Germany).
The sudden disappearance of Ottonians already was a blow when it came to a big succession crisis, but it went worse than that with the return of elective kingship, which settled the agreement of nobles and demonstrations of strength as the norm of deciding a succession when it went relatively smoother in nobiliar successions elsewhere : at worst, elections weren't seen as the normative regulation.
By the death of Henry V, it became an anti-dynastic kingship for centuries, when in France or England, the dynastic principle was well established as even in a succession crisis, elective matters payed little to none influence (and certainly not trough the election of whoever was more popular along nobility). Arguably French kingship beneficied from the sacre which made sovereigns not only crowned, but consecrated beings (increasingly immensely their legitimacy and prestige).
You litterally have to wait for Habsburgs to take the imperial crown in the early XVth century, to really give HRE succession a real stability. By then tough, the ongoing bureaucratization and unification that went trough all Europe allowed not only the neighbors of the Empire to grow in power, but it did happened to all the inner states of the HRE (dukedoms, city-states, principalities, etc.), which saw themselves reinforced and autonomized when it came to imperial order (it did happened in France, similarly, but it was mostly concerning great princes as Burgundy's and even there, it wasn't that solid)
It doesn't mean that medieval HREmperors past the XIIth century were weak (Honestaufen dynasty would be a good counter-example) but the shaky succession and the quasi-legitimized nobiliar revolts meant they weren't able to gradually curb down feudal autonomies and had to establish a working relationship with them (whereas English kings dealt with this in England proper since the Norman take-over, and French kings establish a feudal hegemony from the XIIIth onward which only greater princes were able to fight back) : the Golden Bull of 1356 is basically an acknowledgement of this, and an mostly successful way to establish a legal hegemony of the emperors over their imperial subjects.
Nothing sudden in this case, but gradual.
By the Late Middle-Ages, tough, nothing was irremediably done : HREmperors still beneficied from the unyfing tendencies (it would be the least, giving they provided a good part of incitative to them), and were still able to call on impressive resources they could on their own nobiliar demesnes. But they lacked the same systematized unifying and centralizing structures that had centuries to dominate elsewhere, and had to deal with subjects that didn't wasted their time using these for themselves. Habsburgs remains, still, a dynasty that were mostly successful enforcing their domination in the XVth century, in spite of divisions and foreign intervention : remember that by the XVth and early XVIth, while more unified, France still was including important and quasi-independent principalties as Louis of Bourbon's.
And that's where Protestantism kicked in. Religious fervour, regardless if sincere, convenient or (probably) both, provided a huge bundled opposition to Imperial rule, supported by neighbors (France, Sweden, Papacy), and ended with a huge financial blackhole, forcing Charles V to split up his pretty much immense holdings. HRE managed to maintain itself as a power, as emperors still managed to pretty much balance between the needs of imperial unity and their own interests (while France underwent the joys of civil war), but only for a while as the gap widdened between Protestant nobles' demands, Catholic nobles' demand, Pontifical's demands and Imperial policies (which were generally more or less moderate, a bit like French politiques) which explain (but only partially : bad political choices from Rudolf and Matthias as well) why HRE didn't went the way of Bourbons when it came to re-establish orders (as well, the lesser financial capacities of HRE since the XVIth).
The last proverbial and historical last drop was the Thirty Years War, which was a full-scale, bloody and devastating conflict with virtually everyone in the HRE switching side, and all neighbors as Sweden or France from one hand, Spain and Poland from another taking sides, the former interested on durably crushing the imperial power, the latter more interested supporting Catholicism and catholic factions than increasing imperial power.
At the end of the war, the principle of quasi-independence of HRE states (what we ended up to call the principle of Westphalian Sovereignty) was established, and HREmperors definitely unable to push their authority over a collection of quasi-independent states. The dissolution of HRE in 1806 was more or less a formality.