An IP address doesn't tell you anything about the device. As well as machines setting host names as Kamil explained, printers and scanners and cameras and storage devices can all have helpful names built in. So you might see names like "Inkjet Printer Model 1234" and "Digital Camera XYZ". Deciding which one will print your document is much easier than trying to choose between 192.168.1.11 and 192.168.1.12!
If you have more than one of a device, you can very often change the names, but for something like a printer, the name that's set at the factory is usually good enough. So to answer the second part of your question, for many devices, the names are assigned by being burned into ROM at the factory.