..so yeah, they shaved it because the helmet was really hot (not just because of the sun, also because of the activity etc..the helmet was/is quite heavy and thick you know.) They let the rest of their hair hang out from the helmet when in battle, and on their so called leisure-time they tied the hair over the bald spot to beautiful specialized knots.
The "commoners" (other citizens than warriors) admired the style and tried to copy it, and they could also do so, but their knots were different (more simple?) than those of the warriors (/samurai).
I can't answer why,but do know it was customary amongst pre-modern specific Nomadic tribes ( males ) of Khitan 契丹 & Jurchen 女真 in present day China's NE provinces ( old Manchuria ).Japanese people have strong ancestral roots to this particular region on the Asia continent.