Bacteria on the skin can infect hair follicles and oil glands especially when the skin is broken e.g through shaving or friction. This can happen on all skin of the body including on the penis. Washing gently with mild soap and water will reduce the bacteria on the skin.
This answer was posted on August 22, 2018.
This answer was updated on February 7, 2022.