Part of publication, as we all know, is editing. There's the revising we all do long before anyone is interested in reading, much less publishing, our work—and then there are the many rounds of editing & revising done after you've signed your shiny new publishing deal. Even if your book is "perfect," it will, at the very least, be seen by a proofreader, and probably by copy and line editors.
- A dirty little secret of the querying process is that, even if your book isn't ready for publication, publishers could acquire it and then employ a developmental editor to transform your book from "having potential" to "ready to publish."
All of that is fairly standard, and after each editor sees your manuscript, you will go over it to incorporate their notes. In your contract, you should watch out for any language limiting the time you have to do your part of the editing. The end of this fairly lengthy process is something that's called "Delivery & Acceptance." Basically, you deliver the finished manuscript to the publisher, and the publisher decides whether it is in fact ready to be published.