The law today is so without heart and consideration of the people involved at times.
Sounds like the builder made the mistake...took someones property..and then sued the rightful owner because the owners property was “enriched” by their building. Maybe an amiable settlement could have been made...like owner keeping the house...and builder losing it...but my guess is that builder tried to play hardball and the judge forced them to clear out the property and lose lots of money. The builder can certainly salvage a certain amount.
The owner can maybe sue for “unlawful detainer” of her property...her property was illegally prevented from being developed the way she desired. Pros usually have surveyors and governmental land management peeps giving out permits and inspecting the building progress. A few folk dropped the ball.