It depends. (So many answers start that way!)
Sometimes publishers deliberately pay more advance than they expect the book to earn in royalties. If you have such a book, you’re counting upon selling enough copies that the other costs of producing it are a smaller than normal slice. This leaves more for you to give the author. Unrealistic advances are a way to give a higher royalty to the author without setting a precedent for future agreements.
On the other hand, sometimes (most times? Nah, just seems like that some days) acquiring editors are more optimistic about the book’s sales potential than they should be. When they err by a large amount, this can result in the advance being unintentionally too large to earn out.
That still doesn’t mean that the book was a loss, but it certainly means that the contribution to overhead and profit was less than expected. It probably ISN’T shouldering its full share of the overhead involved.
On the other side of the equation, the advance may earn out and the book may still lose money. Suppose that you offer the author a very small advance. And suppose that the book needs a more expensive design than you expected, and then costs more to print. You could have modest sales, and have the advance earn out, but not cover the rest of your expenses.
Sadly, this distinction between advances earned out and the bottom line is one that is routinely blurred by the press. It’s a pet peeve of mine, especially when it appears as a headline like this:
Y% of Books Lose Money
Argh. At least YOU won’t be misled after having read this post. I hope.
[If I haven't been clear, do please let me know. I'm not a writer, but a number cruncher, so I don't always notice when I'm being opaque.]
Later note: The issue of sub rights has been raised. Authors are usually entitled to 50% of any sub rights revenue. This helps defray any unearned advances, but it increases the publisher’s bottom line, too. Sizable sub rights sales float all boats, but the mix of variable and fixed costs for the book may mean that the advance is covered before the book breaks even, or vice versa.