What usually happens is, say the company has received $x million in funding. Everyone is plugging away working hard, but runway starts to run short and the product isn't getting the traction originally anticipated. At that point it looks obvious the company will go bankrupt relatively soon, so the investors push for a sale to try to recoup some of the their money. Often times there is value in the team and perhaps industry knowledge to the acquiring company, but the tech itself is often worthless, so the sales price is below the $x million capital raised and only holders of preferred shares get anything.
Note that founders rarely own preferred shares. They have common stock just like employees, so they are usually wiped out, too, in cases like this.