Dwarf hamsters squeak because it's the one way they have to communicate to other hamsters when they are young. Their squeak is the vocalization of their feelings. A loud squeak to another hamster signifies that it doesn't like what the hamster is doing, or that it's scared or bothered by the other hamster. A soft squeak means it enjoys the other hamster's company or that it wants the other hamster to pay attention to it. Other types of hamsters, like Teddy Bear hamsters, are quieter because they have longer vocal cords to make softer murmurings that other hamsters can hear. Dwarf hamsters, who are smaller in all regards, aren't able to make softer noises, so they communicate through squeaking.
Dwarf hamsters squeak when they are picked up and held. They do this because they are very small, and a person's hands are very large. Other types of hamsters might squeak a little when picked up, but bigger types of hamsters will learn that they are safe. Dwarf hamsters are so much smaller than other types of hamsters that they never quite feel safe when picked up. Not knowing where they are is frightening for a hamster. If a hamster has been held before, it usually doesn't squeak as much, but because dwarf hamsters are so small, it often bothers them. If it has been held too hard before or scared while being held, it might squeak each time you pick it up.
Some dwarf hamsters learn what it sounds like and what it looks like when they are about to be fed or get a special treat. If your dwarf hamster squeaks when you get out the food bag, or when you open its cage to give it some vegetables or fruit, it has learned these signs. If your dwarf hamster has bonded with you, it might also learn what you look like and sound like, and might squeak when you approach the cage to say hello. Dwarf hamsters share this trait with other types of hamsters, although most owners say that dwarf hamsters are louder than other types.