The cargo space crafts are not designed to transport humans. Check out the Cygnus space craft. It delivers supplies, then burns up in Earth’s atmosphere upon reentry.
Here’s a timeline of events I found online (this is copy/pasted):
-Butch Wilmore & Sunni Williams were planned to be up there for 8 days. A quick test flight of Boeing's starliner capsule.
-That Starliner almost didn't even make it to the ISS - helium leaked and thrusters malfunctioned on the way.
-NASA and Boeing spent the summer trying to figure out what went wrong and whether the problems would repeat on the flight back, endangering its two test pilots. NASA ultimately decided it was too risky and ordered the capsule back empty in September.
-NASA launched the next crew rotation mission — Crew 9 — in September carrying just two crew members, Hague and Gorbunov, instead of four. Wilmore and Williams then joined the Crew 9 fliers aboard the ISS for a normal-duration six-month mission.
-NASA cleared the way for Crew 9's return to Earth by launching 4 replacements— Crew 10 commander Anne McClain, pilot Nichole Ayers, cosmonaut Kirill Peskov, and Japanese astronaut Takuya Onishi — last Friday.
The astronauts were never actually “stranded” as there was always a craft there that could have taken them home. However, if they would have taken it, it would have messed up the scheduled crew rotations (and left the others without a space craft), which is why they stayed put until now.