According to this highest upvoted answer, "but still include it in the blockchain as a "failed transaction"... What is meant by the term "gas"?
A transaction may succeed or fail depending on when/where it was mined. The initial state matters and that is only knowable when the transaction exists in unambiguous transaction order.
Consider getting paid on the same day rent is due and your landlord has a post-dated check. The order of events, the transaction order, may be the determining factor (if your available balance is less than the value of the check).
Did you have sufficient funds when they cashed the check? Did the check bounce before necessary funds were received?
A signed transaction is like a signed check. We do not know if it will succeed or not until we try. The result will depend on what came before. In blockchain, as with checks, it is possible to avoid failure by only signing transactions that should clear. It is also possible to front-run pending transactions perchance to create the conditions that will help a pending transaction succeed even if it was set to fail given conditions at the time it was signed.
The blockchain is a well-ordered sequence of transactions. This includes transactions that failed. The important factors are recorded - who signed it, what the message contained, and the transaction's position in the canonical transaction order.
Since failure deducts a gas cost from the sender, the fact of the fail is important to record. It is part of the canonical story that explains the world state. It's not unlike a bank statement with the bad news. There must be an explanation for the calculation of the balance going forward.
Hope it helps.