Yeah but he doesn't realize that what he did was wrong
, he just knows he's liable to be punished for it if he's held responsible. There's a huge difference between knowing something is wrong and knowing that you can be punished for it. The Joker's a sociopath that really doesn't know right from wrong and views the world and all the people in it as his personal playthings, and he's basically playing his own version of cops 'n robbers. He's trying to fake a completely different insanity, a more "lolrandom" kind, akin to disorganized schizophrenia - this doesn't mean he's not insane, just that he's faking one kind of insanity while being a different kind.