Oh H. I thought I was the only one! Isn't this frustrating! ARRRGGGHHHH!
I have the added problem that DH is the stay-at-home parent so they are inclined to listen to him anyway. And both DSs are very mommy-is-a-treat and daddy-is-stale-bread as it is, even WITHOUT undermining any authority I might have had.
My husband has gotten better, but he still does this. What I did to make him back off (when he remembers) was to talk to him when the boys weren't around and we weren't exhausted (yeah, finding this type of time was hard!). Here's what I said:
"I need you to do something for me. It is really important, and I NEED it. When I'm trying to discipline one of the boys, I'd like you to stay out of it. Leave the room if you have to, but stay out of it. As it is I have no authority, because you jump in and are the bad cop. So the boys don't listen to anything because they wait until YOU say it. I know you're just trying to help, and I love that about you. But I really need you to let me be the bad cop on my own. Please."
then follow up with:
"I know this will be hard, because it's a habit. So if I'm trying to discipline one of the boys and you start to try to be the bad guy for me, I will look at you and say [whatever your code word is, ours was simply "please daddy"]. If I say that I would like for you to leave the room."
Then you need to do what you have said you will.
I still have to use "please daddy" sometimes, but he has gotten so much better. He didn't realize that trying to be my hero by being the bad guy for me was such a problem. Good luck!