Because it's making things that are useful to you. The cost of operating Rivian as a zombie company for a few more years might be less than the cost of replacing their vans or finding another supplier for parts.
(You might say that in that case Amazon should be willing to pay enough for those parts/maintenance to make Rivian profitable, but they might be willing to pay more for an in-house department that will operate the way they want than for an external company that might waste money continuing to chase other revenue sources instead of gracefully winding down)
In a scenario where Rivian fails and AWS buys it out of bankruptcy it would presumably cost a lot less than 17 billion. That it's currently burning a billion per year is exactly why it might be worth bringing in house, where they can presumably cut that by a lot.
(You might say that in that case Amazon should be willing to pay enough for those parts/maintenance to make Rivian profitable, but they might be willing to pay more for an in-house department that will operate the way they want than for an external company that might waste money continuing to chase other revenue sources instead of gracefully winding down)