Both ""_8^16"O" and ""_8^18"O" are stable isotopes, and both were originally formed in stars.
Formation of ""_8^16"O"
When a star runs out of hydrogen to fuse in its core, it begins to collapse until the central temperature rises to 10^8color(white)(l) "K".
At this temperature, the α particles can fuse rapidly, and ""_8^16"O" is formed in a "triple alpha" process.
""_2^4"He" + ""_2^4"He" → ""_4^8"Be"
""_4^8"Be" + ""_2^4"He" → ""_6^12"C"
""_6^12"C" + ""_2^4"He" → ""_8^16"O"
Formation of ""_8^18"O"
In contrast, ""_8^18"O" is formed mostly in massive stars.
The processes involved are
""_6^12"C" → ""_7^13"N" → ""_6^13"C" → ""_7^14"N" → ""_8^15"O" → ""_7^15"N"→ ""_8^16"O" → ""_9^17"F" → ""_8^17"O"→ ""_9^18"F" → ""_8^18"O"
Thus, ""_8^18"O" is much less abundant than ""_8^16"O".