A home sale is often more complicated than that. In some places, you can buy a house “as-is,” meaning that effectively the seller is largely not on the hook as long as they didn’t egregiously misrepresent the condition of the house.
In some places, you can also sell a house as "condemned" and then you have no recourse what-so-ever.