So, there was a beginning. A beginning to what? To time, to the universe, to created life. And before that beginning, God was already there.
When I was a child, I used to try to think hard about a time before time. I'd close my eyes and put my fists to them until I could see "stars" and imagine that was before time began. The knowledge was always beyond my reach but maybe if I tried harder, it would come to me.
There was no time before time was created. That still boggles my mind. How do you mark your days and years? Or know when you have your dentist appointment? There would be no clocks or calendars and London would be without Big Ben.
And if there was no time, how was God there? Wasn't He started at some time, did He have a birthday? We know that He had a Son - Jesus. Did Jesus have a starting day? I still don't understand how someone can exist outside of time.
I heard an illustration once that helped me with this. Imagine a ruler, and that ruler is the timeline from creation to the end of the earth. Someone from outside of that time can see the whole of time and come in and out at several points.
Another illustration was something I did when I taught Sunday school. We made a 3-d platform and then put a 1 dimensional person on it. What can the 1 dimensional girl understand about the 3 dimensional platform? If she can only see one side of it, and only explore it as a 1 dimensional person, she will never really understand it fully.
So God, who is fully dimensional, made the heavens and the earth. I am a 3 dimensional girl, limited in what I can see and understand. But perhaps I don't need to understand things fully. Because God will tell me what I need to know and to leave the rest to Him.