Developing symmetry is is just a matter of Homeotic genes creating axial patterning, genes that produce a chemical gradient across a cell or group of cells. This is how developing organisms orient individual cells, up, down, left, right, anterior, posterior, medial, lateral, are all just gradients of different chemicals, the cells can detect the difference in concentration one one side or the other to orient itself. Most of these start getting produced when the embryo is only around a few cells so there is not much room for ambiguity. Later more homeotic genes are added to create gradients for things like segments and limbs. Note polarity is often exhibited in a single cell, even in single celled organisms, this is a chemical gradient that orients the inside of the cell, this can easily be turned into orientation of dividing cells.
As for why things move away form this symmetry that's easy, evolution can mostly only work with what it has, evolution is about good enough not perfection. Often good enough creates a kluge, a rube goldberg type solution then descendants then get stuck with. The earliest vertebrate ancestor pikaia is completely symmetrical even down to the gut, A fish is nearly perfectly symmetrical, with the only deviation being to increase the length of the gut without increasing the length of the fish, which would waste a lot of material The solution is to coil and pack the intestines instead of having a straight line. This does not just happen in vertebrates you can see these solutions again and again in mollusk, insects, and even echinoderms, keeping the body compact while making the gut longer means asymmetry. As Some organisms progressed further and further away form the "fish" body plan alteration would result in asymmetry. Lungs for instance force a big asymmetry because you are taking what was a simple one way path into two divided systems, blood now has to return to the heart twice before making a complete circuit. More energetic animals specialize even further abandoning or partitioning part of the circulatory system to close off these two parts entirely so they can have high pressure blood flow without exploding their lungs. Now asymmetry is not a bad thing limbs and sense organs stay symmetrical because there is a stronger evolutionary pressure to keep them symmetric, moving with asymmetric limbs wastes a lot of energy (try running with only one shoe on).