Short Answer
The short answer is the the six water molecules on the left-hand side come from CO2, as a by-product of reduction. That is, carbon dioxide may (formally) be though of as the source of the oxygen atoms in the six RHS water molecules (with the protons coming from 'the environment') 1†.
In photosynthesis, only half of the oxygen atoms of CO2 are lost to reduction.
The balanced equation given by the OP (Eqn 1 below) acknowledges this, and envisages that the other half remain as part of the synthesized hexose.
In photosynthesis, reduction of carbon dioxide is incomplete. If we reduce CO2 all the way to methane (an 8-electron reduction) both oxygen atoms are lost, and (in the simplest case) end up as water.
By inclusion of 12 water molecules on the left hand side, the balanced equation also acknowledges that the 12 reducing equivalents (24 electrons) required to make glucose from 6 CO2 all come from water and give rise to 6 dioxygen molecules (that is, oxygen is 'split').
In short, the six waters on the RHS result from the reduction of carbon dioxide, whereas the twelve LHS waters provide the necessary 12 reducing equivalents.
We need to add here that Eqn (1) applies to green-plant and cyanobacterial photosynthesis: not all photosynthetic organisms use water as electron donor, or produce O2 as a by-product.
Equations of Photosynthesis
The equation given by the OP (Eqn 1) is the overall balanced equation for green-plant and cyanobacterial photosynthesis (see Abeles, Frey & Jencks, 1992, p 635, for example) 2†:
$$\ce{6 CO2 + 12 H2O -> C6H12O6 + 6O2 + 6H2O \tag{1}}$$
We may summarize as follows:
12 reducing equivalents (24 electrons) are required to reduce 6 carbon dioxides to 1 glucose. These are supplied by water.
Water is the source of the oxygen released in green plant photosynthesis (not CO2)
In the reduction of CO2, six carbon-carbon and six carbon-hydrogen bonds are 'made' (thus accounting for the requirement of 12 reducing equivalents).
The reduction of 6 CO2 produces six water molecules as a by-product.
The reduction of 1 CO2 requires 2 reducing equivalents (four electrons). Or, 2 water molecules are required to reduce 1 CO2
- CO2 is 'fixed'
In addition, we may add the following:
- The reaction is thermodynamically unfavorable, where the free energy necessary (about 600 kcal/mol) being supplied by sunlight (Abeles, Frey & Jencks, 1992).
But green plants and cyanobacteria are not the only photosynthetic organisms, and not all photosynthetic organisms use water as a source of electrons (or evolve oxygen).
Some photosynthetic bacteria use hydrogen sulfide (H2S) and 'make' elemental sulphur rather than oxygen. The balanced equation may be written as follows:
$$\ce{6 CO2 + 12 H2S -> C6H12O6 + 12S + 6H2O \tag{2}}$$
It can be seen that although no water appears on the right-hand side of the equation, water is still produced as a result of CO2 reduction.
A balanced equation describing photosynthesis in general may now be given, where H2A is any substance that can be oxidized to A (Abeles, Frey & Jencks, 1992):
$$\ce{6 CO2 + 12 H2A -> C6H12O6 + 12A + 6H2O \tag{3}}$$
Other examples of H2A are H2, isopropanol and lactate.
The Reduction of a Single Carbon Dioxide
We may note first of all that the oxidation of two water molecules to a single O2 is a four electron (two reducing equivalent) oxidation.
$$\ce{H2O + H2O <=> O2 + 4e^- + 4H^+ \tag{4}}$$
The photosynthetic reduction of a single carbon dioxide may be represented as follows (Abeles, Frey & Jencks, 1992) and we may note that this is a four-electron reduction:
$$\ce{CO2 + 2H2O^* ->[$hv$] (CH2O) + O2^* + H2O \tag{5}}$$
The asterisk indicates that if oxygen atom in water is labelled (using an isotope of oxygen, for example), the label is found in the oxygen 3†.
In green-plant photosynthesis, the (incomplete) reduction of 1 CO2 requires two reducing equivalents which are supplied by 2 H2O, and this four-electron results in the formation of 1 O2 and 1 H2O.
Oxidation and Reduction
I suspect that most readers of this post will know all of what follows in this section. Nevertheless, what is and isn't oxidation/reduction seems to sometimes cause confusion and some examples may help to clarify.
Oxidation is the loss of electrons. Reduction is the gain of electrons. A hydration is neither an oxidation or a reduction, and neither is an ionization.
Some examples
The reaction shown in Eqn (6) is an oxidation (ethane is oxidized to ethanol). (Electronegative oxygen has 'taken' a pair of electrons from the second carbon atom, which is oxidized)
$$\ce{CH3-CH3 +\frac{1}{2} O2 -> CH3-CH2OH \tag{6}}$$
The reaction shown in Eqn (7) is neither an oxidation nor a reduction, but a dehydration (the dehydration of ethanol to ethylene). The oxygen atom has not been oxidized or reduced. It 'owns' the same number of electrons in ethanol as in water. (A good example of a hydration/dehydration reaction from the world of biochemistry is fumarase. The formation of malate from fumarate is not an oxido-reduction in any sense). This is an important one.
$$\ce{CH3-CH2OH -> CH2=CH2 + H2O \tag{7} }$$
The reaction in Eqn (8) is a reduction (the reduction of the carboxylate group of acetic acid to the aldehyde (acetaldehyde)), but note that the oxygen in water has not changed its oxidation state. When water is eliminated, it leaves 'taking with it, in terms of electrons, what is already owns'. But, unlike the previous example, the tetravalency of carbon is 'maintained' by the 'acquirement' of a pair of electrons (reduction).
An example from the world of biochemistry, is the aldehyde dehydrogenase reaction, where NAD+ acts as electron acceptor.
$$\ce{CH3-COOH + 2H+ + 2e- -> CH3-CHO + H2O \tag{8} }$$
Eqn (9) is also a reduction (the reduction of acetaldehyde to ethanol). An example is the alcohol dehydrogenase reaction.
$$\ce{CH3-CHO + 2H+ + 2e- -> CH3-CH2OH \tag{9} }$$
This final example (Eqn 10) is an ionization (the ionization of acetic acid), and may not under any circumstances be considered either an oxidation or a reduction (all the electrons 'stay put').
$$\ce{CH3-COOH -> CH3COO- + H+ \tag{10} }$$
(When dealing with oxidation and reduction, protons are 'free'. We may add them in or take them out without changing the oxidation state).
Rant
Failure to distinguish between hydration/dehydration and oxidation/reduction has led to claims that water in the Krebs cycle is a source of reducing equivalents. Racker, for example, claimes in A New Look at Mechanisms in Bioenergetics that electrons from water are transported down the respiratory redox chain, and Wieser claims that water provides 'the additional reducing equivalents needed to transform the chemical energy of one molecule of glucose into that of 36 molecules of ATP'. Both of these claims, IMO, are nonsense (see here).
A Final Look at CO2 Reduction
Let's take a final look at the reduction of CO2 (where carbon is 'fully oxidized'), and reduce it by adding reducing equivalents (pairs of electrons) one-at-a-time until carbon is fully reduced, that is until we reach CH4. (We will also need to add a pair of protons at each step, but as far as oxidation and reduction is concerned, as stated above, these are 'free').
Adding a pair of electrons to CO2 gives formic acid, adding a further pair gives formaldehyde plus a molecule of water, adding another pair gives methanol, and adding a final pair gives methane plus another water molecule
This is summarized in Eqn (11).
$$\ce{CO2 ->[2H+, 2e-] {HCOOH}->[2H+, 2e-]{HCHO} + H2O->[2H+, 2e-]
CH3OH->[2H+, 2e-]CH4 + H2O }\tag{11} $$
The oxygen atoms in the water molecules eliminated in steps 2 and 4 have not changed their oxidation state.
To fully reduce carbon dioxide to methane requires 8 electrons, and the two oxygen atoms are eliminated as water. To reduce six carbon dioxide to one gluc ose requires 12 reducing equivalents (24 electrons). If nature had decided to make hexane ($\ce{CH3CH2CH2CH2CH2CH3}$) the photosynthetic storage product, this would have require 19 reducing equivalent (38 electrons), and if methane was the final photosynthetic product, then 4 reducing equivalents (eight electrons) per CO2 oxidized would have been required.
Footnotes
In the 'real world' of green-plant photosynthesis, the oxygen is 'lost' as phosphate, not water, in the glyceraldehyde-3-phosphate dehydrogenase reaction (see here), a key step in photosynthesis where reducing equivalents enter the carbon skeleton (see here). The electronegative atom (oxygen) 'eliminated' to 'accommodate' the incoming reducing equivalents does not have to be part of a water molecule (or, in a more general sense, have to be oxygen at all).
In the case of aerobic respiration, the general equation may be given as follows, which emphasizes that 6 O2 atoms give rise to 12 H2O (six 4-electron reductions), and that (formally) 6 waters are consumed in the production of 6 CO2. Subtracting 6 waters from both sides, as is sometimes done (see here), only leads (IMO at least) to confusion.
$$\ce{C6H12O6 + 6O2 + 6H2O -> 6 CO2 + 12 H2O \tag{12}}$$
- This experiment was done by Kamen and Ruben (1943), using 18O as tracer. Martin Kamin and Sam Ruben are credited with the co-discovery of 14C, that great gift to biochemistry and science as a whole. Sam Ruben died of phosgene poisoning, which he was preparing for the war effort during WW2. The story of his death is poignantly told by Martin Kamen in Radiant Science.
References
Abeles, R H. Frey, P. A., Jencks, W. P. (1992) Biochemistry Jones and Bartlett
Kamin, M. D. (1985) Radiant Science, Dark Politics. A Memoir of the Nuclear Age. University of California Press. Google Books