Depending on what addon it is and where you get it from, will dictate if you can use the code. It is always a good idea anyway to give credit to the person who wrote the code. I will use my addons for a example. My addons do not have a license with them, but here at wow interface all uploaded addons are considered all rights reserved, unless otherwise stated in the addon's description and or the license file that would accompany the addon.
nUI is basically 1 large addon that modifies all of the User interface. You also have UI compilations which are multiple addons arranged and put into a pack for people to download. Each of the addon in the pack unless it is a license that the author allows you to freely use the addon, you should get permission.
As far as learning, I would suggest taking a addon that you use that isn't a monster and looking at the code and how things work, there are also several websites and books you can buy. I personally have both versions of
http://wowprogramming.com/store you can also find some other books there.
When you do decide to take the leap and understand a addon make sure its something simple, don't go trying to understand a addon like auctioneer.