How was the earth created if it's flat?
That depends on the cosmological context of a Flat Earth.
If the Earth were the center of the universe, it wouldn't really matter how, purely that it were the divine work of God.
If the Earth were one world amongst trillions of others, I presume you mean to ask:
"What astronomical mechanism did God engineer to allow Flat Earths, or planes in general, to form of their own cosmologically bound laws?"Now that, may be unanswerable.
Yet to entertain the notion, of course we could hypothesize as to variable laws of gravity, or of quantum mechanics, or indeed of necessary spacial environments for life and so forth.
Things like that.