My mother whines alot. I understand she doesn't feel well alot, but she instantly changes when my husband walks in or someone calls her. I am her caregiver yet I get the whining and complaining. My husband gets the best side of her and she takes his side in everything.
I find it annoying beyond tolerance when a grown human behaves like a spoiled child.
You can stop this by ignoring her when she does it. Only engage with her when she is talking appropriately. Tell her that you will not speak with her until she stops, she will probably throw a few tantrums until she figures out that you are serious and you will not be dealing with it any longer.
I would also record her so you have evidence of her behavior.
She probably shouldn't be trusted with any issues between your husband and you if she is always taking his side. You never know what she is saying behind your back.
This behavior is a form of manipulation and should not be entertained.