Parents make mistakes, parents make bad decisions, and they suffer the consequences. After all, that's why we teach our children that consequences result from bad decisions and can often be unpleasant. We are not all angels and never will be.
how do we teach our children from the mistake that we made and still be able to stand our ground if they do the same thing and need some form of a consequence.
We need to model good behavior while acknowledging that everyone makes mistakes and bad decisions. Acknowledging that perfection is not the end result of discipline, but rather what is of importance is an approach to life in general is what makes our mistakes forgivable.
We make mistakes; we do wrong.
We apologize.
We promise to be more careful in the future.
When restitution is in order, we demonstrate that as well.
Parents need to model the right behaviors, so when a child witnesses a wrong behavior but it doesn't affect them directly, by all means, 'fess up and have a discussion about your bad decision. Give yourself a consequence (for example, many people fine themselves for swearing: money goes into a "swearing jar".)
Hypocrisy is something that kids pick up on very quickly. So yes, when witnessed, act how you want your kids to act.
Regarding bad behavior that they did not witness or suffer consequences for, would I confess to my children that I ran a stop sign and didn't get caught? No. I would not burden them with that information.
However, if I got caught, I would certainly let them know about my "punishment". The ticket, the points off my driver's license, the increase in my insurance premiums, the mention in the local paper, all because of a bad decision. After all, this is why we're teaching them about consequences.
Showing them that you have consequences for bad behavior is absolutely appropriate and reinforces why we set the limits on kids that we do.
Similarly, my kids certainly didn't openly admit all their transgressions to me, nor did I expect them to. One of my kids cheated in school. He didn't confess. Once I caught him, once the school caught him. His consequences were very significant, even though I was not the injured party.
In the end, I think it comes down to modeling the behavior you want in your kids and learning of life lessons. Our kids are not our confessors, but if we transgress against them or in their sight, we do what we want them to do. In my case, that was a sincere apology, a promise to try to avoid that behavior in the future, and restitution when possible.
Edited to address the OP's comments.
I once blamed my children for something they didn't do, and worse yet, I didn't believe them when they said they didn't do it (I don't remember this myself; my kids told me this a few years ago.) I mistakenly disciplined them for the action and for what I believed was a lie. When I found out that it was my husband who committed the offense, my kids told me that not only did I apologize profusely, but that I gave them each a hefty sum of money to pay them for the time they put in as a consequence. I was shocked by the amount they quoted; I can only imagine I was following my own principles of making restitution significant.