Your correct that some of it is loneliness. But it can be a symptom of senile dementia, OCD, and even Alzheimer's. I worked with elderly people and many were hoarders of just about everything. The most unusual was the lady who refused to let the Sheriff remove a dead horse from her parlor. She was pretty handy with a shotgun! But seriously, it can start out with something as simple as accumulating newspapers that they're going to read some day. Some how it gets out of hand.
A lot of those who lived during the Depression keep huge quantities of certain things. My late mother used to buy up a lot of non-perishable items, particularly paper products like paper towels, tissues, toilet paper. I used to joke that we could have our own market in the basement of my mother's house. I think a lot of those who went through that era became traumatized at not having enough of certain things that they began to keep too much of everything. But that said, my mother never got to the extreme hoarding stage...to the point where you couldn't move in her house because of so much stuff or the house became uninhabitable.
It doesn't take much to cross the line from pack rat to extreme hoarder.