I'm just going to add a dimension to several of the answers above.
I asked a musician friend who was playing in a cover band how he could learn and remember his part in so many songs so quickly (including both singing and guitar playing of various types). This was a diverse American pop and Polish immigrant favorites cover band, and they were always learning new songs. He told me that fter you've played enough, you know all of the moves, so to speak. You know what kind of patterns are likely to be played in what order, and you're just mixing and matching them in different ways, so it's easy to remember.
Learning programming languages and libraries is like that. When you've been doing it long enough, you know the finite set of things that a language or library designer is likely to put into the package if they have any sense, and it becomes easy to guess how things will be done. In essence, you learn which choices were made from a menu you already know, and then you learn the exceptions--the quirks of the package, which might have to do with novel functionality that it's trying to implement. For libraries, it also helps if you are already familiar with the concepts of the domain for which the library is designed. For example, it's a lot easier to learn a library for credit card processing if you already know a different credit card library.
The exceptions to this pattern occur when a language depends on a paradigm that's unfamiliar to the experienced programmer, as when someone who's always done procedural programming learns an object-oriented language, or when an object-oriented programmer switches to a strictly functional programming language. Or when learning something that was intentionally designed to thwart programmers' expectations, like so-called esoteric languages.