In the first case you have (where it's an appropriate b'racha) the רמ״א (in 209:1) is quite clear that you're okay:
וכל שכן אם היה בידו יין וסבור שהוא מים ופתח אדעתא לומר שהכל ונזכר ובירך בורא פרי הגפן שיוצא שהרי אף אם סיים שהכל יצא (טור):
Surely if he had wine in his had, and thought it was water, and started with the intention to say Shehakol, but remembered and actually said Borei Pri Hagaphen that he fulfills his obligation. After all, even if he would finish with Shehakol he would also fulfill his obligation.
Now for your next two cases (where it's an inappropriate b'racha), we have the Mechaber (in 209:1):
ויש אומרים שאם לקח כוס שכר או מים וסבור שהוא של יין ופתח ברוך אתה ה' אלהינו מלך העולם על דעת לומר בורא פרי הגפן ונזכר שהוא שכר או מים וסיים שהכל יצא
Some say that if one took a cup of beer or water and thought it was wine and started saying Baruch Atah Hashem Elokeinu Melech Haolam with intention to say Borei Pri Hagaphen, but remembered that it was actually water or beer and say Shehakol, he fulfills his obligation.
The Mishnah Berurah there indeed says that this is the Halacha. He also explains:
על דעת וכו' - היינו אע"ג דבשעה שהזכיר שם ומלכות שהוא עיקר הברכה היה דעתו על ברכה שאינה ראויה לאותו המין כלל אפ"ה כיון שחתימת הברכה הזכיר בפיו כהוגן יצא בדיעבד:
[quoting...] - That is even though at the time he said Shem and Malchus [i.e. ברוך ... העולם] which is the main part of the B'racha his intention was for a B'racha which is not relevant for that "type" at all - even so - since he ended the B'racha by actually saying what was proper, he fulfills his obligation (בדיעבד).
So it turns out that even if you pick up your pasta and somehow think it's water and have intention to say Shehakol, but then realize your mistake and end correctly - you fulfill the obligation. In your case, which appears to be even better (after all, you were just "spazzed" as you said in your comment), the same should apply.
Note: I'm tempted to say that cases #4 and #5 are the same, but I'm still working on it... Will edit in later if I find something...
So on my first read of the question, I was assuming that everything above was going on in his mind and the only thing he actually said was ברוך ... העולם and then stopped.
However, if that point is passed, timing is critical. He must correct himself within a timestamp that is known as "תוך כדי דיבור". However, if he does accomplish that time span, he can correct himself even after reciting the entire B'racha.
In other words, as is explicitly said in the Mechaber (in 209:2):
לקח כוס של שכר או מים ובירך ברוך אתה ה' אלהינו מלך העולם בורא פרי הגפן ותוך כדי דיבור נזכר שטעה ואמר שהכל נהיה בדברו וכך היתה אמירתו ברוך אתה ה' אלהינו מלך העולם בורא פרי הגפן שהכל נהיה בדברו יצא.
If someone took a cup of beer or water and said the entire B'racha of ברוך ... הגפן and then "Toch K'dei Dibbur" remembered and said "שהכל נהיה בדברו" so that the entirety of his speech was: "ברוך אתה ה' אלהינו מלך העולם בורא פרי הגפן שהכל נהיה בדברו" he has fulfilled his obligation.
"Toch K'dei Dibbur" is a time period, which The Laws of Brachos (by Rabbi Forst) says is somewhat less than 3 seconds. [The actual meaning is the time it takes to say Shalom Alecha Rebi (Mishna Berurah 206:12. However, the Taz 206:3 adds U'mori).]
Another important note: All the above seems to specifically apply to standard (i.e. virtually all) B'rachos which are only מדרבנן. A notable exception would be ברכת המזון which - if one eats his fill - is מדאורייתא.