Most of what you're asking can be found on a [couple][1] of [articles][2] on the minecraft wiki site, but I'll summarize the big points:

 - Villages are specified by the existence of doors that meet certain conditions. For a door to be counted as "in a village," the door must have more blocks on the outside than on the inside and a villager must exist nearby - no more than 16 blocks horizontally and 3 to 4 blocks vertically. A block is counted as inside if it is shaded from above. A block is counted as outside if the sun hits it from above. [Here are some common techniques for registering doors.][3]

 - If the distance requirement for a villager nearby a door is not met, the door can become unregistered after some time. That can be resolved by destroying it and replacing it.

 - Each door can support .35 of a villager, i.e. you need about 3 valid doors for each villager (more precisely, every 20 doors support 7 villagers).

 - The boundary condition seems a bit hazy, but the 16 block requirement in the first point seems to imply that it's 16 blocks from the most outlying door. However, villagers can move up to 40 blocks beyond that before they actually unregister from their village.

 - You must have at least two villagers if you want to start an entirely new village. That means you've got to find a village and transplant villagers from there. The reason for this is that new villagers are created by "making love" (villagers are genderless, so any 2 will do).

 - Villagers will attempt to birth new ones when the village can support more than the current number, as per the third point (doors can support .35 of a villager).

 - Iron golems spawn when there are at least 16 adult villagers and at least 21 valid doors.

 - Iron golems and villagers both will wander aimlessly if they are not created naturally or are not in a village, respectively.

  [1]: http://www.minecraftwiki.net/wiki/Iron_golem
  [2]: http://www.minecraftwiki.net/wiki/Village
  [3]: http://www.minecraftwiki.net/wiki/Tutorials/Creating_NPC_Villages#House_designs