Have you ever played with clay or Play-Doh? When you squish it down with your hands, it gets smaller and denser, right? That's kind of like what a compactor does, except it's for waste like garbage and other materials that we don't want.
A compactor is a big machine that can squash a lot of garbage or other materials into tiny, tight blocks. This makes it easier to store and transport the waste. When trash is put into the compactor, a big metal plate pushes down on it really hard. This makes the garbage get squished together and become much smaller.
Think of it like making a sandwich. When you lay down a slice of bread, then put peanut butter and jelly on it, you add another slice of bread on top. The sandwich is now just a little bit bigger than the bread was by itself. But if you press down on the sandwich with your hands, all the ingredients get smooshed together and the sandwich becomes smaller and denser. This is what a compactor does, only with garbage instead of bread and peanut butter.