In the U.S., rules of court have the prosecutor in a criminal trial giving the first opening statement, followed by the defense's opening statement; and then the final closing statement, after the defense's closing statement.
Giving the prosecution both the first and the last word seems like obviously tilting the scale of justice in its favor, and against the accused. If so it would seem to violate the legal principle in dubio pro reo and associated customs and practices to assume an accused is innocent unless proven guilty beyond a reasonable doubt. At the very least an outsider might think it more fair to have opening and closing statements in the same order: I.e., if the defense speaks last at opening then it also speaks last at closing.
What are the origins and reasons for this custom of giving the prosecution the first and last word at trial?