He told Padme, didn't he? Did she keep it a secret? Surely Obi-Wan would know through the Force, as well as perhaps other Jedi. Why wasn't he punished for his crimes?
In the film (and novelisations), it's not clear that Padmé told anyone about the incident, nor that Yoda was aware of the full extent of Anakin's actions other than that he'd been involved in something that had caused him great emotional distress (his mother's death). Assuming no-one knew what he'd done, there would be no reason for him to face any censure.
In the Attack of the Clones novelisation we see that Padmé actually approves of his murder-spree(!) and attempts to convince him of the rightness of his actions:
He ignored her. “Not just the men,” he went on. “And the men are the only fighters among the Tuskens. No, not just them. The women and the children, too.” His face contorted, as if he was teetering between anger and guilt. “They’re like animals!” he said suddenly. “And I slaughtered them like animals! I hate them!”
“I hate them!” he insisted.
“And they earned your anger, Anakin.” [said Padmé]
He looked up at her, his eyes wet with tears. “But it was more than that,” he started to say, and then he shook his head and buried his face against the softness of her breast.
And in the Revenge of the Sith novelisation it's made clear that Anakin kept the precise nature of his actions in the Tusken camp secret from the Jedi leadership (but not his pal the Chancellor):
“Don’t be afraid, Anakin [said Palpatine]. What is said between us here need never pass beyond these walls. Anakin, think: think how hard it has been to hold all your secrets inside. Have you ever needed to keep a secret from me?”
He ticked his fingers one by one. “I have kept the secret of your marriage all these years. The slaughter at the Tusken camp, you shared with me. I was there when you executed Count Dooku. And I know where you got the power to defeat him. You see? You have never needed to pretend with me, the way you must with your Jedi comrades.
Do you understand that you need never hide anything from me? That I accept you exactly as you are?”
As far as the "civilised" peoples of Tatooine are concerned, the Sand People were little more than vermin. On a world where the Hutts (renowned for their criminal actions) were in charge and Republic law doesn't hold sway, there doesn't seem to be any particular legal issues that would result from killing them, even in large numbers.
Aside from the facts listed by @Richard, there was nothing to punish legally wise (as opposed to Jedi internal disciplining).
Tatooine is outside the jurisdiction of the Republic, so the Republic government wouldn't care in the first place.
Sand People are a hostile force, the killing of whom is not frowned on on the planet itself (as we see from "Kenobi" Legends C-canon novel by Miller). It's done by moisture farmers, Jabbas, anyone, really.
Remember that Padme spent at least two days with the Lars family. Cliegg mentioned that nearly the entirety of a search party were slaughtered. a search party which included people close to the Clieggs, perhaps even the parents of some of Owen's close friends.
Her approval rating of the Tusken Raiders was likely negative at that point...
The only people who knew about Anakin's massacre of the Tuskens were Padmé and Palpatine. And both kept it a secret from anyone else. I suspect Padmé believed that the Tuskens deserved their fates. In her eyes, they had kidnapped an innocent woman (Shmi, whom Padmé had known in The Phantom Menace) and slowly tortured her to death for a period of a month. I wouldn't be surprised if she shared Cliegg Lars' opinion that the Tuskens were "not men".
As for Palpatine, I suspect his knowledge of the massacre was merely an emotional tool he could utilize or exploit to turn Anakin. Ironically, Anakin seemed more upset over his actions than either Padmé or Palpatine.