funny question. editing an os from within itself is quite fine. an os can modify itself during runtime if it needs be. such a design can make one more flexible but a poorly executed one can leave wholes for viruses to wreak havoc.
as for what comes first, look at the mac. OS X was designed long before the computer it was made for was conceivably possible.
now your question does not state whether the computer the os was designed on is the same computer the os will be used on. they can be different (as with the mac world) or they can be the same (as with the unix world). obviously the computer the os was designed on must be made first. you can always compile a program to run for a completely different architecture. for an os, you can have it put onto a diskimage then have the image applied onto the actual hard disk of the other computer (for example making an os for a pc on my mac) if your a good programmer and left few minor bugs then the other computer will start up fine.
with linux, people always compile new kernels from within the old one
of course its not wise (if your editing the code that is), but if you don't care about crashing the system, then by all means play around the source code and keep recompiling and restarting all day