Two ways, generally
Someone tells us or we see the results of what we did when sleep walking
Some people save themselves a lot of embarrassment by waking up on their own before anyone sees them. They then go silently back to sleep and wake up the next morning with the choice to tell someone and voluntarily embarrass themselves or just be quiet. Really, no need to be embarrassed, it's involuntary.