Age 2 To begin with, don't make a big deal out of it.
Toddlers are curious about everything, including their bodies.
At this point, your toddler's exploration has less to do with sex than it does with cause and effect. Simply put, he's discovered that touching himself feels good, so he does it. Tell him that you understand that what he's doing feels nice, but that certain activities are best done in private. Suggest that he retire to his room when he feels like touching himself. If you're searching for an analogy, compare it to how Mommy and Daddy need privacy when they take a shower or use the bathroom.