The School of Salamanca about value and money said something else in 16th century. The Spaniards were anything but dumb.
It just happened that the British industrial revolution steamrolled everyone. You can't compete aganst the steam engine and the railway making communications and sharing of goods and raw materials something ridiculously cheap compared to the previous times, even by boat in both UK and Spain where the big rivers like Douro and Tagus could sustain a lot of transport. But, still, the train allowed to reach anyone in the country.
Which cheap transportation you can connect industrial powerhouses (and competent engineers and scientists) and the rest it's history. Addthe telegraph on top of that and it's game over for any outdated empire. When knowledge sharing can be reduced hours and maybe a day or two instead of weeks or months, it's like upgrading from having a 486 based computer with DOS to a Ryzen one with multiparallel processing. Literally.