Why don't they complete all anime episode before airing? In Shirobako (an anime about making anime), they only make some first episodes and then continue to finish the other while the anime is airing. This cause some problem when they can't catch up the deadline, and also may affect the quality of an episode too.

In real life, there are some anime that do have this kind of trouble like Kekkai Sensen or God Eater in the last season.

So why they don't just finish all episodes before airing, at least for short range anime (~12 eps).
As Justin Sevakis mentions in his article on The Anime Economy:

Anime production is an extremely labor-intensive proposition, employing the services of up to 2,000 people per episode around the world. Most of the grunt work is now done in third world countries across Asia, and the use of digital technology has reduced costs across the board. Anime production is now as efficient as it's ever been.
That said, a single anime episode costs about US$100,000-300,000 per episode, according to various producers we've talked to. That might seem like a lot, but in reality it's pretty cheap, about on par with an American deep-cable TV show. (An American prime-time TV show can cost well into the millions.) But multiplied across 13 episodes, that nonetheless turns into a total budget of US$2-4 million.
That's a lot of money. Few companies are rich enough to invest that much in a single show. If it tanked and they lost all that money, most would never be able to recover.

What we understand from this is:

The production of each episode of anime is costly and most often, the studios cannot afford to produce a whole season before they air it.



The truth is, producing an anime is a herculean task: a gigantic amount of money and manpower get poured into every production well behind the scenes, before a single drawing is even created. The stakes are huge for every company involved, and every season will have a number of winners and losers.


They cannot afford to &quot;risk it all&quot; on an anime without airing it and noticing how it is received by the public. This doesn't mean that they can air a special episode before airing the main anime to decide whether the anime has a potential to be popular on not. There are many anime and shows which lose viewership during the course of the anime and all this has to be taken into account while making another episode. As Ross mentions in the comments, &quot;Also, if the show gets cancelled or its run shortened they don't waste money on episodes that will never air.&quot;


As mentioned in this article:

While many people describe studios as being cheap, only around half the budget is often given to the anime studio, with the rest going to broadcasters and other contributing companies.
Once things get going, the producer has two basic responsibilities: make sure that the show is made well, and recover all the millions of dollars that the Production Committee spent in the first place.


They need to maintain a flow of money to tackle the loan they've taken and to arrange for the remaining budget of the show.

Note: This answer has been compiled assuming that the adaptation material for the manga is sufficient for the anime in question.

TL;DR: The main reasons that anime production does not involve finishing the production of the entire anime before airing it are:

Anime production needs as many as 2,000 people for the production of a single episode with the price ranging from US$100,000-300,000 per episode. In most of the cases, the studios cannot afford to produce a whole season before airing it because even a 12-13 episode series takes as much as US$2-4 million.

The stakes are huge for every company involved and every season will have a number of winners and losers. Hence, they cannot afford to &quot;risk it all&quot; on an anime without reviewing the reception of the anime by the fans and it's popularity. If the show gets cancelled or it's run shortened, they can avoid wasting money on episodes that will never air.

Only around half the budget is often given to the anime studio with the rest going to broadcasters and other contributing companies. Hence, it's the producer's job to ensure that the show is well received and to recover the millions of dollars that Production Committee spent in the first place. Hence, they need to maintain a flow of money to tackle the loan they've taken/to arrange for the remaining budget of the show.



I've also contacted Justin Sevakis asking him this very question, since he seems to be an expert on these matters and his answers cover almost all points. If he writes back, I'll update this answer to mention the highlights of what he writes as an answer.