If sanji could dodge everything but chooses not to cuz he is into BDSM he could've taken him to safety, and saved someone his captain promised safety to.
Also vegapunk didn't want necessarily to die, he was ready to die which is different, and had a whole setup about it.
Still convinced it's not bad writing?
It's not that every single time Sanji's been hit in the history of the manga, he could've dodged and actively chose not to.
It's more that Sanji fights recklessly and takes more damage than he needs to because he doesn't care to protect himself half as much as he cares to protect others.
Now he's realising he needs to love himself too and that will boost his defensive abilities, in addition to later gaining CoC.
That doesn't mean he would've been able to do anything more to protect Vegapunk. Kizaru was simply massively faster and stronger than him.