I think you're misreading what they've been doing with her character. She hasn't been becoming bipolar, she's been acting like a spy for her group since they first arrived at Alexandria.
Her transition from demure housewife to apocalyptic survivor who's prepared to do whatever it takes to survive (and general badass) has been going on for quite some time. Remember when people where getting sick at the prison? She did what she thought was necessary to protect the group and then played it cool afterwards. Rick, of all people, thought she went too far and had her leave the group.
And remember when everyone was trapped in Terminus? Carol didn't exactly ask politely for her friends to be released.
I'd suggest you rewatch the episode Indifference, way back at the start of season four (episode four):
The whole episode hinges on how much her character had already transitioned by that point.
With all that in mind, I don't think there's any question that she's only been pretending to be meek and innocent while in Alexandria. That incident with Sam wasn't Carol having a bipolar moment, she was lifting up the mask she'd been wearing so that she could make sure Sam didn't cause trouble for her.
Maybe you could argue that her character's changed to much over the series (though I'm inclined to think the apocalypse might have a profound effect on your character), but it certainly hasn't just started in Alexandria.
Also, while she, along with everyone else, misses the civilized world she used to know and the simple pleasure of making a good casserole, I wouldn't take that scene in the pantry to mean she was nostalgic for cooking for her husband. Ed was abusive, after all, and when she finds out what Pete's been up to she makes it clear to Rick that there's only one way to handle the situation, and making a casserole doesn't figure into her plan. (Well, not at first, anyway: https://m.youtube.com/watch?v=KQFFv2CFoTM .)
Personally, I felt like Carol was far from a blood-thirsty ninja when Alexandria was invaded. Yes, she saved the group, yet again, and killed without hesitation, but she looked like she was on the verge of tears when she had to euthanize the woman from the pantry. And when she takes one of the cigarettes at the end it really seems like the events have taken their toll on her. In that moment she doesn't seem the least bit blood thirsty. Rather, she understands what it takes to survive in the horrible world they're living in, and she's determined to do what it takes no matter how hard it is.
Really, despite all the unremorseful killing, there's a lot of subtle emotions running under the surface of Carol, and once you appreciate those her actions make a lot more sense. (Her character definitely wouldn't work without the amazing acting chops of Melissa McBride.)