While humping the legs of someone else isn't neccessarily normal, a little "self play" can be. As you said, he is imitating (or so he thinks) something he saw you doing.
First, since he is so young, it is likely he doesn't really understand what he saw. He might think it is one more way to show his uncle he loves him, or a type of game or any number of things so punishing is not likely to help as it is probably just confusing things further.
The first thing I would consider would be a discussion if you haven't had one with him already. This discussion should take place at any time when you can take your time with him and when it is not inspired by finding him in the act of humping your brother's legs. The fact that he is changing the subject is a sign he is embarassed and/or confused. He may not fully understand what he is doing and why.
At a separate time, Ask him if he has any questions or thoughts about what he saw you doing. Not to accuse you of anything, but you probably acted embarassed when he saw you (I know I would) and maybe haven't taken the time to answer his questions. Create the time now. If he tries to change the topic, chalk it up to he doesn't have the vocabulary or self-awareness to express himself about it.
Then, you might try explaining what he saw with something along the lines of calling what he saw a "special hug" between two people who really love each-other. It is important to include that this hug is shared in private and that it is for people who love each-other in a way that is different from how a nephew loves his uncle or a mother loves her son. It is a type of hug that can only be given between two people who BOTH agree they want the hug (your brother, of course, doesn't want the hug). You might also put an age on it to indicate that it is a hug for adults so he doesn't start asking preschool mates to join him in a "special hug".
The second thing I would suggest, again, if you haven't already done so, is only participating in "special hugs" when he is out of the house or you are on the other side of a locked door. Your son simply isn't ready for viewing this activity and it has shown in how he is behaving after viewing you. Help yourselves out by taking steps to avoid a recurrence.
If he begins engaging in "self play" he has discovered a new "toy" as it were. The sensations he feels are not the same as the sexual sensations an older boy would have, but he has now discovered a new feeling that he is experimenting with and figuring out. If that occurs, please don't punish him, just encourage that certain activities are done in private (like going potty) and so if he needs to explore he should do that when he is alone and in private (like his bedroom or the bathroom). Then, try not to worry about it too much. Good luck.