british commonwealths are basically "you run the show, while allowing us to pretend to be your ruler". Does anyone honestly believe Canada or Australia aren't independent countries?
Britain had the good fortune of finding that losing colonies (the US) was actually better business than keeping them, because British colonies were trade partners rather than extraction industries. the mercantile system was bad for Britain, because of costs of occupation, while they were the world's leaders in lower cost goods. Spain, on the other hand, had a colony system based on extraction, because the mother country wasn't all that industrialized, which is what it would take for there to be a good trade economy. Thus, Spain was less likely to prosper by stepping back and letting the colonies be free.
It also helped that Britain was basically a republic, nominally allowing a king or queen to claim sovereignty, while Spain was a monarchy constantly trying to retain absolutism. Both had really shitty royals, but Spain, outside Carlos III, was especially shitty. Britain had the advantage of a parliament to actually run the show, and at the right moments, they allowed colonies to go free with the pretense of still being colonies.
Britain saved face, and expenses by allowing the colonies to attain virtual independence, but still held fantastic trade relations, because Britain was the world's industrial leader. Spain allowing colonies to go virtually independent simply meant turning them over to British sphere of influence.
IF, and it's a really big IF, because Spanish royals were notoriously incompetent simpletons (and circa 1800 no royal would want to go to the americas), they had set up royal blood in the americas, it's possible they could have set up a commonwealth system nominally allied to the mother country, but realistically, those royal commonwealths would quickly realize better trade arrangements lie with Britain, or France. Still, it would have been better than OTL for both sides.