Why does the oxygen produced in the photosynthesis come from water and not carbon dioxide?
You are missing some knowledge here for sure, photosynthesis is a little complicated at A level, so I will describe it in brief.

During photosynthesis electrons and protons (A hydrogen atom without the electron) are required for a process called the electron transport chain and proton motive force. This happens during the light dependent stage of photosynthesis, (there is also a second light-independent stage called the Calvin cycle, and that is where the CO$_2$ is used), I won't go into detail about what the protons and electrons do (unless you want me to) but you need to know that these come from a water molecule, the water is split using light (photolysis, literally: cutting with light) into two hydrogens and half an oxygen molecule (or an oxygen atom). The oxygen that was released in photolysis is not required for the rest of the pathway, so it diffuses out of the cell.

For why it doesn't come from carbon dioxide, you need to consider the Calvin cycle. In the Calvin cycle, carbon dioxide is converted to glucose by enzymes, using products from the light dependent stage, so 6CO$_2$ are combined over six cycles to form one molecule of glucose. So that is where the CO$_2$ is used as well. 

Hope that helped! If you want me to go into any more detail please ask!