The meaning behind this idiom is vulgar, and often isn't explained. Indeed, it is hard to explain politely.
In elementary school, in the United States, when a student asks to leave the classroom to go to the bathroom, the teacher may want to know how long the student will be gone. There are two reasons to go to the bathroom. In the old days, the student would raise his hand with either one finger or two, to indicate the reason.
(This custom had already died out when I was in elementary school, but I think it was still customary in the 1930s).
Thus, in US English, "number one" and "number two" can be euphemisms for the two reasons to use the bathroom.
In the phrase, "to do a number on," "a number" is a humorous way of "number one or number two."
If I'm not clear enough, you can find straightforward definitions of "number one" and "number two" in the Cambridge Dictionary
https://dictionary.cambridge.org/us/
And that is all I am going to say.