However, water is also a part of Earth. Then how can the Earth be raised from water.? How to know ocean exsisted out of ocean?
The explanation is given in Shreemad Bhagvat Purana ,where the story of Varaha avatara is discussed in detail.SB 3.13: The Appearance of Lord Varāha
It's said in that chapter that earth was submerged in the great water.
यदोकः सर्वभूतानां मही मग्ना महाम्भसि ।
अस्या उद्धरणे यत्नो देव
देव्या विधीयताम् ॥3.13.15॥
yad okaḥ sarva-bhūtānāḿ mahī magnā mahāmbhasi
yatno deva devyā vidhīyatām
O master of the demigods, please attempt to lift the earth, which is
merged in the great water, because it is the dwelling place for all
the living entities. It can be done by your endeavor and by the mercy
of the Lord.SB 3.13.15
So at that time earth was submerged in flood water i.e. by a deluge. At the same time the earth itself was under water of ocean.
So what is this ocean? There were two oceans one was on earth ,and one was inside which earth itself was submerged.
सृजतो मे क्षितिर्वार्भिः प्लाव्यमाना रसां गता ।
किमनुष्ठेयमस्माभिः सर्गयोजितैः ।
यस्याहं हृदयादासं स ईशो विदधातु
sṛjato me kṣitir vārbhiḥ plāvyamānā rasāḿ gatā
anuṣṭheyam asmābhiḥ sarga-yojitaiḥ
yasyāhaḿ hṛdayād āsaḿ sa
īśo vidadhātu me
Brahma thought: While I have been engaged in the process of creation, the earth has been inundated by a deluge and has gone down
into the depths of the ocean. What can we do who are engaged in this
matter of creation? It is best to let the Almighty Lord direct
It's said in Dwadasha Skanda -Chapter four of the same Purana ,which is describing four types of Annihilation's
that at the time of Annihilation the shell of the universe gets fully submerged in water forming single cosmic ocean.
So at that time the earth as whole was also submerged in cosmic ocean ,which forms during Annihilation .i.e. Pralaya. So at the time Lord Varaha lifted the earth ,the ocean in which she was under was the ocean formed during previous Annihilation (Pralaya).
शतं वर्षाणि वर्षन्ति नादन्ति रभासस्वनै:।
तत एकोदकं विश्वं
ब्रह्माण्ड विवरान्तरम् ।।12.4.13।।
tata ekodakaḿ viśvaḿ
At that time, the shell of the universe will fill up with water, forming a single cosmic ocean.SB 12.4.13
Thus there were two separate oceans. one was on the earth which was filling whole earth ,and the other was cosmic ocean from the time of previous Annihilation.