Skinheads (and remember, the skinhead scene wasn’t racist or neo-nazi in the beginning, and there’s been a strong non-racist/anti-racist skinhead scene since the late 60s) shaved their heads for a couple of reasons. The original skins were working class kids in the UK, both the white teens and the children of immigrants from Jamaica and other West Indian islands. They started to mix the mod styles with the rude boy image brought over with reggae, rocksteady, and ska.
As the mod scene got fancier and began sort of tying into the hippie scene in terms of fashion - brighter colors, friilly shirts, longer hair - the working class “hard mods” deliberately went the other way. So the shaved heads were partially in reaction to that. It was also easier to keep clean and neat when you did physical labor (and those that didn’t still wanted to look like they did). And although the early skins were not political or, as a group, racist (though there were certainly racists among them, as individuals), they did like to fight (see: football hooligans) and short hair means there’s nothing to grab hold of in a brawl. Plus, when you have a group of guys and they all want to look basically alike, shaving everyone’s head is a good start.
So, you’ve got all that feeding into the style and soon enough it’s just a subculture marker. The media started calling them “skinheads” (after also being called peanuts, baldies, etc) and it was pretty much set in stone. In the late 70s, nationalist/racist groups like the National Front started recruiting among these kids and telling their other young followers to pick up the fashion, since skins were known for being violent thugs anyway. The media picked up on “nazi skinheads” and there you go. Bald = racist.