The situations are very different.
But.
Every strawhat knows that sanji will never be able to win against a woman. That's just sanji. So every strawhat (including robin) knew that sanji was facing off against a woman.
So what happened there?
Sanji knows that robin would be strong enough against black maria, so he trusted her, as a friend and nakama. And asked for her help.
As for the argument that he put robin into danger because kaido and bm wants to have her...
They are in onigashima, fighting against both kaido and bm. If they lose, robin is literally in kaido's hands. She has nowhere to escape and no one to help her escape. And not only her life is doomed but also the lives of everyone else fighting against kaido + bm (including luffy and co).
In this situation, what is the right choice to do?
Should sanji let himself be killed? Do you believe thaz robin would be safe then?
Or should he ask a friend for help, so that he can instead go and fight someone strong (for example king, queen or jack)?
Which of those 2 options would be the best for robins (and everyone elses) safety?
Ps. I don't like that sanji can't hurt women even in such extreme situations, but it is, what it is. So he made the right choice.