Moderate health expertise.

Two questions:

Is there a cut or a visible wound on the surface of your penis? If so, then you have rubbed yourself so raw to the point that it broke the skin. The clothing and no lubrication is a key factor.

Second, did the blood come from "voiding" (urethra). That could mean infection of the urinary tract and you should seek help for that asap.