Suction cups work by having less air pressure on one side than the other, thus forcing them against the surface they stick to. So, despite the fact that it seems like the suction cup is pulling on a surface, it is actually being pushed against it. Pushing a suction cup down forces out the air and stops air from leaking in, creating a relative vacuum.
Because they work by maintaining a vacuum, suction cups are usually made of flexible materials, like rubber, and they work best against very flat surfaces, like a glass window. Surfaces with rougher textures tend to stick less reliably, and a surface that is too rough for the flexible suction cup material to fill in the gaps will not stick to a suction cup at all.
Because suction cups rely on air pressure to work, lower atmospheric pressure makes it difficult for them to stick. Air pressure is not the only type that will work, however. Any pressurized fluid will cause a suction cup to stick to a surface. On earth, air and other fluids push against all adjacent surfaces because of gravity. It is literally the weight of the atmosphere that pushes a suction cup against a surface.