You ask where God was before He created heaven and earth.
This is something which is not easy for us, with our practical minds, to understand. Because we have bodies which need a place to live, we find it hard to imagine that God is Spirit (John 4:24) and does not need such a place.
We only know that the Bible tells us that God existed before all things (Psalm 90:2) and though He has his home in heaven,
a place we cannot even imagine, He has also chosen to live in the hearts of his people (Isaiah 57:15).