Why do rabbinical fasts(i.e. all fasts apart from Yom Kippur) which start on Erev Shabbos still end at tzeis hakochavim if we are forbidden from fasting on Shabbos?
First of all, I will point out that this halacha is in dispute. The Beis Yosef brings from the Raavid that as soon as one begins (tosefes) Shaabos at sunset he should end his fast, and the Tur brings from the Maharam that one may even end his fast as soon as he davens and accepts Shabbos before sunset (completing the fast meaning until one actually starts Shabbos). As pointed out by @GershonGold, there may be Poskim who say like this. (As always, CYLOR.)
As for why the main opinion of the Shulchan Aruch is to fast until tzeis hachochavinm, it would seem that this is based upon the shita of Rabenu Tam, that until tzes it is not considered that the sun has set. We see this in the Rosh who writes:
מתענה ומשלים פי' אם ירצה ולא הוי כמתענה בשבת וכיון שיכול להשלים אם ירצה והוא קיבל עליו תענית סתם וכל תענית שלא שקעה עליו החמה אינו תענית צריך להשלים עד צאת הכוכבים
[And the halacha is that one] "fasts and completes", meaning if one wishes to, this is not considered like fasting on Shabbos. And since one is able to complete [the fast] if he desires, and he accepted upon himself a fast without conditions, and any fast that the sun does not set upon it is not considered a fast, he must complete [his fast] until the stars come out.
Saying that the end of a fast with sunset is the same as when the stars come out is the opinion of Rabenu Tam, as explained elsewhere in the Rosh.
According to the Rosh, the time between sunset and tzes hachochavim is tosefes Shabbos, the time that we add on to Shabbos. This is not the actual day of Shabbos, so fasting during this time is not like fasting on Shabbos itself. Even during the end of that period when it is bein hashemashos and Shabbos has already started from safek, since it might still be considered part of the day, and completing the fast is allowed, as this is still considered only coming into Shabbos while fasting, and not actually fasting on Shabbos.