Williams lost to No. 2-seeded Simona Halep 6-3, 6-3, ending a bid for her first title in the event since 2001. Williams, who also won in 1998 and 1999 when it was played on Key Biscayne, was making her 20th appearance in the tournament.
Andreescu retired with a right shoulder injury while trailing Anett Kontaveit 6-1, 2-0. Andreescu, who is tied for the WTA lead with 20 match victories this year, said she felt pain and tightness in the shoulder.
"I've played so many matches," the 18-year-old Canadian said. "I guess it's just my body's way of telling me it has had enough. The doctor said it's nothing too serious, but the pain is there."
Andreescu said she will skip the tournament next week in Charleston, South Carolina, but plans to play the Fed Cup on April 20-21.
She called a medical timeout after the first set to receive treatment and received similar treatment during her third-round victory over Angelique Kerber, who afterward called Andreescu the "biggest drama queen ever."
Andreescu defeated Kerber in the Indian Wells final on March 17 for her first career title.
The injury ended Andreescu's bid to become the fourth woman to win Indian Wells and Miami back to back. "I'm pretty upset," she said. "But I really can't complain, with what I've achieved."
Halep and Kontaveit were joined in the quarterfinals by Petra Kvitova, who faced only one break point and beat Caroline Garcia 6-3, 6-3. Kvitova, a two-time Wimbledon champion, is ranked a career-high No. 2 and will rise to No. 1 if she wins the title. No. 1 Naomi Osaka lost in the third round.
Kvitova's match was interrupted by rain for more than 90 minutes, and she took advantage.
"I had a quick nap, which was really helpful," she said.