A little bit of google-fu would have helped here. Not that you are not right to ask: it's perfectly fine. But the very first thing you should be able to do is to find information yourself, read the doc, and so on.
Get the source code
What you describes is distro specific. For instance for Debian and derivatives (such as ubuntu) apt-get source [package] is what you need (see here for instance or man apt-get source or search engine). This way, one can edit the sources of the versions of the programs that are used in the distro.
If what you want is to contribute to an open source project directly, you shouldn't use distro specific sources but the upstream sources usually managed by a version control system (quick how-to for git and github, assumes that you already know what we are talking about).
Make your own distrib
There is nowhere to start from. There aren't good practices. But if I were to forge a new distro, I would begin by wondering why I want to create a new one. Isn't there a distro out there that would fit my needs? If not, is there one that is close enough to ask its maintainers whether they are interested by a new contributor?
Code compilation
It depends on a lot of things. But usually for compiled languages, a
./configure --prefix=[install directory]
make
make install
should do it, but again, read the doc. Packages are usually release with INSTALL or README files, read them. And again, your favorite search engine should give you all the details about how and what to do to get your system ready or to solve common problems (99.99% of them are common).
General thoughts
- Read the doc (man pages, local doc, web doc, etc.).
- Extensively use your favorite search engine to answer your questions and keep stackechange and other websites for clarifications or questions that have really not been answered elsewhere. I got dozens of relevant pages just by typing your questions on google.
- Get used to Linux distros such as ArchLinux and Gentoo once you are comfortable with Fedora/Ubuntu: you should learn a lot from them. Their Wiki/Handbook are also supergreat!
- Visit Linux from Scratch website.
- Don't by too hasty. Take your time and be sure to be comfortable before trying something knew.