In the same way that a bad parent who becomes a better parent knows they are now a better parent.
That's not a great example. There are loads of bad parents who think they are good parents. There's a bit of Dunning-Kruger effect, and also some bad parents who hold beliefs about what makes a good/bad parent that differ from the norm (i.e. some parents think beating their children is OK and think that modern society is wrong to condem that practice. They think they are good parents because they beat their children. This is wrong)