It sounds like you abraded your skin with the washcloth, and then the soap probably had some strong perfumes and whatnot in it, and those irritated the damaged skin. Just be gentle with yourself from here on out; and masturbating with soap is fine s long as you don't also use an abrasive object like a washcloth! It might not seem abrasive at the time, but it can damage delicate skin. You penis should heal up in about a week, but it may be tender for a while. Wash with a soap that is fragrance free, and labled "hypoalergenic", and that should ease up on the pain during a shower.
Soap can be a great lubricant during masturbation
and sex! Water can make body parts "stick", but soap lets everything slide nicely. Plus, you clean inside at the same time ;) just make sure that if you are sensitive or allergic to some things to use safe soaps to avoid irritation.