A sampler doesn’t synthesize sounds so much as it plays back sounds that were recorded from somewhere. The recordings are stored digitally in memory, so they can be triggered instantly when you hit a key on your synth. They can also be sped up and slowed down to achieve different pitches. Sampled waves can be trimmed, looped, reversed and manipulated in many other ways to achieve whatever sound you are looking for.
There is no limit to the types of sounds that can be created with sampling. Samplers have been used to achieve great realism (mapping multiple separate recordings of each note of a grand piano to each key), and they’ve also been used to make music out of sounds from things that aren’t normally considered instruments (think “Jingle Cats”).
Samplers often have large libraries of sounds available for them, but they also give you the ability to record your own sounds via microphone or line input.
Another implementation of sampling that uses samples built into Read Only Memory where they can’t be edited is called a rompler. Romplers don’t let you record your own sounds. Most of your typical home keyboard synths are romplers.