I once read that passes in the Alps were designed not to go over 7-8% so horse carriages could cope with the gradients. So if needed, the road would make another hairpin (at almost all costs) to avoid steeper sections.
But for most (smaller) mountain roads, they once were goat paths and the more road / pavement = more money and labour to build them. So it's cheaper to have it straight up the mountain at 15%, and when it goes over e.g. 20% they make a hairpin. But some mountains are very rough terrain and don't allow for too many hairpins, e.g. it's easier to traverse a section with a big rocky slope than to make hairpins in that section, even if that means a certain stretch goes over 20%.
To add to this, many of the mountain passes in the Alps will have been long distance trading and transit routes (for those carriages and caravans) and would have had fairly large strategic importance - think about how important some of the Italian cities were as merchants and traders, and the relationships in the Middle Ages between for instance the Holy Roman Empire and Rome. What's more, taking a route to avoid - for instance the Alps - is very difficult, so it's incumbent to make these routes not so steep to allow for easy travel as there is no other option. Think if you want to take something from Milan or Venice to Munich, to avoid the Alps you either have to go along the coast to Nice and around through Northern Switzerland, or you have to go along the coast and through Slovenia and around to Vienna - neither of these would be faster than a mountain pass, so there was an economic incentive to make passes that were as easily passable as possible. The Gotthard pass for instance has been there in some form since the 13th Century and was first paved in the early 19th century.
In contrast, areas like the Picos de Europa are quite small in area so finding a way around is very easy, and it's near the coast so it doesn't separate two strategic areas. So making a route to go over isn't needed in the whole, so these tend to be farming routes for moving cattle that have been paved later on in the 20th century. As Volderke mentioned, the groundworks to keep these routes under 10% wouldn't have been viable just for some farmers to move some goats or cows, so they tend to be direct and therefore steeper. This is generally why there is lots of emphasis on 'finding' the next Zoncolan or Angliru, as sometimes there are farming tracks that are unknown to those that aren't local to them.