Because you can’t undo an execution. So there is time to allow for appeals and further investigations to potentially exonerate.
The person to be executed is also often throwing every appeal or delaying tactic at the system they can (guilty or innocent), because people don’t usually want to die.
While it costs a lot to imprison a person for a couple of decades prior to execution, a wrongful death suit from executing someone 10 days after sentencing and then having video evidence showing them at a different location at the time of the crime on day 11 is more expensive. And you’ve executed an innocent person. Generally known as murder.
Latest Answers