Actually it's very unlikely that you would contract genital herpes from touching someone else and then touching yourself. It's just not an efficient way to transmit the virus. In theory it could happen but it's very low risk. Now if there was naked skin on skin foreplay before mutual masturbation that would increase the risk a bit but still overall it's a low risk.
grace
Yes, it is possible. If you touch an area where they have an open sore (mouth, penis, vagina... anywhere) and immediately touch yourself you can definitely get HSV.