I just want to add to @Rarst answer.
I came to understand that quite a lot of the code seems to be the same
Yes, the bundled themes are written by the Wordpress team, so you would expect the coding styles between the bundled themes to be the same.
Can I do the same thing, using code from those themes?
This was handled by @Rarst, but I would like to add to this. The bundled themes are showcases of new functionalities within Wordpress. These themes are used to target these new functionalities and the correct uses there of
Furthermore, these themes suggest the correct way how a theme should be written according to coding standards, although this is not the alpha and omega to coding standards as such.
These bundled themes offer a perfect base for theme developers to create their own themes on, and I believe that is why they should be used for. I've personally combined the twentytwelve and twentyfourteen themes as a base for my previous theme I developed. But you have to keep @Rarst answer in consideration here.
This is just a little useless info, but I always like to add some form of credit to these themes, something in the lines of
This theme is based and written using the twentyfourteen theme as a base........
in my stylesheet under