Why is it that authors will use fragments in writing to emulate speech, but it is considered grammatically incorrect?
As mentioned in Sentence Fragments
This is a conventional journalistic practice, often used for emphasis.
Fragments are grammatically incorrect, since they:
It depends on what you mean by grammatically incorrect. Sentence fragments are not part of formal English, but formal English is only used in certain specific areas, such as professional correspondence or scholarly papers.
Outside of those areas, sentence fragments are common. So long as the audience understands the point, there's no reason to frown on them.
We don't speak formal English when we talk in our day-to-day lives. Therefore, it makes sense that novels will use sentence fragments when emulating speech, as you said.
It's also worth noting, I think, that some sentences that appear to be fragments are actually examples of elliptical construction. For example, the sentences "Fire!" and "Two tickets, please," convey complete ideas, even though they've left out some words. They're not fragments.