Many Achronim offer an answer for Rashi. The Pnei Yehoshua gives an answer based on a sugya in Bava Kama in regards to a מודה בקנס
I will attempt to try and summarize his answer here.
Rashi agrees that if someone walks into Bais Din one day and makes an announcement that he is chayiv misah, of course he would not be able to avoid the death penalty that way. (As an aside, the Marharitz Chiyus points out that if someone does not want to get the death penalty he could just avoid saying "Al das Kein" when the witnesses warn him which is a prerequisite to get the death penalty).
What Rashi is talking about is a case where the Bais Din is judging the case and the person admits a further transgression. In the example he brings, a person stole and the Bais Din was judging this issue when he admitted that he also butchered the animal and sold it. In such a situation, any further witnesses that come will be אינן יכול להזימה since he already admitted it. However this would only work if the Bais Din was already discussing his case.
Therefore in this case as well, since Bais Din was already discussing his case, if he would admit that he actually killed the person, just not in front of these witnesses but in front of others and on a different day, those second witnesses would be impossible to be mazim and would become passul on that account, and he would get off scot free. However, if he walked in out of nowhere, since it was not in middle of a din torah it would not make them אינן יכול להזימה and they would be accepted as witnesses afterwards.
He also explains what Tosfos holds as to why this answer is not sufficient.