This answer is not that easy. A cell that can become anything (omnipotent) or almost anything (pluripotent) is generally known as a stem cell. There are several factors that decide its fate. For one there are external signals to the cells, like growth factors or hormones. For example, if a cell is supposed to become a liver cell, it gets certain signals which lead to the activation of "livergenes" and deactivation for "skingenes" (It's a bit more difficult than that but you get the idea). This activation and deactivation of genes can be done by a whole range of methods, for example acetylation and deacetylaction of histones, methylation of DNA, regulation of transcription (DNA to RNA) or regulation of translation (RNA to Protein). So again, in summary, the cell fate is determined by which genes are active and which are inactive in a cell.
After the egg has been fertilized and has divided a number of times, cells may start to differentiate. What they differentiate to depends on their location relative to other cells. All mammals have a similar beginning, which is why their fetuses, including our own, look very similar. The specifics of what is done to the differentiated tissues depends on the instructions in the DNA.
An afterthought: You might hear on the news that scientists try to generate stem cells from adult tissue. The idea is to reprogramm the cell to its original stem cell-like state. This is not easily done. However, if this works, you could actually use a skin cell and reprogram it to a brain cell or a heart cell.