If God cannot do the logically impossible (like make a square circle), how can he create something from nothing?
What a great question! What is logically impossible is impossible because it contradicts the most fundamental laws of being. With the example of a square circle, not even God can make a thing to be something it is not, as long as it remains what it is. But to make something exist when before it was not is something entirely different. "Nothing" is truly nothing. It is not the contrary of "being" or "existing" as though there were a state of "being nothing." Indeed, that would be impossible.
The expression "create out of nothing" is just an abbreviation of a longer form, which explains what creation is all about. The expression is that God creates ex nihilo sui et subiecti—that is, he creates neither using something of himself (since he is perfectly simple and cannot be divided) or making from some subject that already exists (like a craftsman who makes something out of wood or stone). So, when God creates (and he alone can create), he simply bestows being when there was none. The "nothing" didn't really precede the being, because nothing is really nothing!
The Catechism of the Catholic Church discusses these issues in this way:
We believe that God needs no pre-existent thing or any help in order to create, nor is creation any sort of necessary emanation from the divine substance. God creates freely "out of nothing."
If God had drawn the world from pre-existent matter, what would be so extraordinary in that? A human artisan makes from a given material whatever he wants, while God shows his power by starting from nothing to make all he wants.
Scripture bears witness to faith in creation "out of nothing" as a truth full of promise and hope. Thus the mother of seven sons encourages them for martyrdom:
"I do not know how you came into being in my womb. It was not I who gave you life and breath, nor I who set in order the elements within each of you. Therefore the Creator of the world, who shaped the beginning of man and devised the origin of all things, will in his mercy give life and breath back to you again, since you now forget yourselves for the sake of his laws. . . Look at the heaven and the earth and see everything that is in them, and recognize that God did not make them out of things that existed. Thus also mankind comes into being."
Since God could create everything out of nothing, he can also, through the Holy Spirit, give spiritual life to sinners by creating a pure heart in them,and bodily life to the dead through the Resurrection. God "gives life to the dead and calls into existence the things that do not exist." And since God was able to make light shine in darkness by his Word, he can also give the light of faith to those who do not yet know him (296-298).