But how can a lender do "everything" upfront?

Some things can only be (or should only be) done during the final verification process which is apart of Closing, which shouldn't start until after the merchant has been quoted, made a decision on an offer and sent back contracts. If not, you would be doing a ton of expensive searches and verification on merchants that haven't even decided to move forward yet.

Sometimes merchants don't disclose information upfront, or lie, or something else comes up during the final verification process that either delays the deal or declines it.

One of the things that can be done is to pre-qual the merchant, understand your Funder's criteria up/down/all around, and continue to submit packages that outline the situation of the merchant upfront. But even with this, you still can be victim to something coming up in the final verification process that kills it.