The nicknames were mostly made up by publishers or editors because they believes they sold better that way. That practice took off in the late classical period, and continued through the early romantic until composers worked out that if a piece was going to be lumbered with a name anyway, they might as well pick it.