To answer your second question first, yes, it can do harm to the computer to do a hard shutdown. The shutdown process goes through and closes all programs running, including those running in the background. This process ensures that everything has a beginning (boot phase) and an ending(shutdown phase) and eases the risk of having something fragmented or possibly corrupted.
The fragmenting is easily resolved by running the disk defragmenter or another third-party defragmenting program. Should something get corrupt it might require a reinstall of whatever application said 'something' belongs to.
As far as why it happens, if during a shutdown process a program locks up and can't fully shut itself down, the computer will hang. I've had that happen on a few occasions (typically when running a java ap of some sort like minecraft or a .net program). As I don't know what you're running that could cause the issue, the only thing I can do is suggest that when this happens you run the defrag program fairly soon after rebooting to make sure that everything is resorted properly.