A potential well is a region where potential energy is lower than in the surrounding area. A particle can have a bound state whose wavefunction is concentrated inside. The allowed energies follow from the shape of the well and the boundary conditions on that wavefunction.
In an ideal finite square well, a bound state oscillates inside and decays into the exterior. The interior and exterior solutions must fit together at both edges. Only particular energies meet those conditions. An infinite-wall model instead requires the wavefunction to vanish at the walls.
Changing the width or depth changes which bound states fit. A semiconductor quantum dot uses confinement to give electrons discrete levels, so the device's size can influence the energies at which it absorbs or emits light.
Being inside a well does not by itself make a state bound. In the simple case of a constant exterior potential, the energy of a bound state lies below that exterior value. The wavefunction then decays far away rather than continuing as a travelling wave.