No, they can't both be right; you can't say on one hand that the world happened by accident, but then say on the other hand that it was created by a deliberate act of God -- not if you're going to be logical.
But the Bible is clear: God created the universe. It didn't just happen, nor was it an accident; it was created by a deliberate and purposeful act on the part of God. And God didn't just form it out of a shapeless mass of material that somehow already existed; He created it from nothing. Think of it: God willed for the worlds to come into existence -- and they did! God spoke -- and it happened! The Bible says, "By the word of the Lord were the heavens made, their starry host by the breath of his mouth" (Psalm 33:6). God is that great and that powerful!
The Bible doesn't tell us, however, exactly how God brought about the universe as we know it today. Many devout scientists, for example, believe God may have taken billions of years to bring it to its present form. But never lose sight of the Bible's central truth: "In the beginning God created the heavens and the earth" (Genesis 1:1).
The greatest truth of all, however, is that God loves us, and He sent His Son into the world to save us. By faith put your life into Christ's hands, because in Him alone "are hidden all the treasures of wisdom and knowledge" (Colossians 2:3).