Hospitals are typically kept a little cool for a couple of reasons: the staff is running around working hard, the equipment works better in a cooler environment, and the costs are lower. So the floors and rooms can be pretty chilly. Some of the more modern construction allows each patient to control the heat in his/her own room.
When a person is sick and stressed, it is common to feel colder than usual, because of the way the nervous system operates. Also, most older people (who make up much of the hospital patient population) tend to feel colder much of the time because their temperature control system doesn't work as well as younger folks'.
Some folks want to wear socks to keep their bare feet from touching the floor, which they might (rightly) think is dirty. Or, the type of socks with rubber on the bottom help prevent a person from slipping when they get up out of the bed.
Finally, the blankets supplied in a typical hospital are just not as warm as those you might have at home, so some people wear socks in the bed.
For all these reasons, it's common to wear socks in the hospital.
RN who has experience as a patient!