Both.
If I have an idea for a project I'm first going to search and see if it or something similar is on GitHub. If I find it, I'm gonna look at the code... So this is learning.
If the project is EXACTLY what I want, then I may use it and eventually contribute to it.
If it's not the same thing as what I want and I can't find something exact, then I will create my own project and go through the learning curve, perhaps with some assistance from the open-source code in some modules. You learn both ways.