What “age” 2yo is she? Under 2.5, closer to 3? How is her understanding?
Tbh at this age consequences don’t do much, they can’t really marry their action and the consequence, then make a conscious decision not to do the behaviour next time. So much of their behaviour is reactionary, there is often little thought behind it.
With hitting, especially if she’s hitting a baby, I would immediately move her away, or get up and move yourself and baby. Remind her of gentle hands, remind her “I will not let you hurt me/baby” and say something like “we will be over here when you are ready to be gentle”
With the words, I would be addressing that at the source - her sister. Ask her sister to stop using the words, and when your 2yo does use them give her other words instead so if she says “you’re stupid” you could offer “I don’t like that choice” (because usually they say it when they aren’t getting their own way, rather than a comment on someone’s IQ!) Again maybe something like “those aren’t nice words. I don’t like it when you use them. I’m going to the kitchen now, you can join me when you’re ready to use kind words”
But it all is so dependent on her understanding, and what every situation is. Keep going with what you’re doing, the habits will break