This isn't hard, sometimes you make the same mistake two or three times or even maybe more before you learn to avoid them. But as long as you learn, and you do not make it again, they are still our lessons and they are valuable.
The second condition is that we need to keep detailed records about our trades, after all it is very easy to repeat the same mistake if you cannot identify that you have found yourself in the same position already in the past and that you already made a mistake when dealing with it.
And the third and final condition is to be humble enough to accept there is still something we can learn, this is important as there are many traders that feel they know it all, and if that is the case then there is nothing left for them to learn, so only those which admit their own shortcomings have any ability to learn from their mistakes.