A contact fails slowly, and then fails faster
The spring that presses against the side of a lamp base is phosphor bronze, chosen because it holds its shape at temperature. But "at temperature" has a limit, and a lamp socket runs warm for hours at a time. Over years the bronze anneals — the internal stress that made it springy relaxes — and the contact pressure drops. Less pressure means a smaller contact area, which means higher resistance at the joint, which means more heat at exactly the point that is already hot.
That is a feedback loop, and it is why a flickering lamp gets worse over months rather than staying the same. The flicker itself is the joint making and breaking as the metal expands and contracts, and every break draws a tiny arc that pits the surface a little more. By the time you notice it, the socket is the part that has changed — the bulb is still perfectly good.
Which gives you a test that costs nothing and needs no tools: take the bulb out and screw it into a different lamp of the same type. If the flicker stays with the original lamp, the socket is at fault. If the flicker travels with the bulb to the new lamp, the bulb is. Nothing else in this job is as decisive, and it is the step people skip because changing the bulb feels more obvious than moving it.
The bulb's own contact, and the one that looks like a fault but is not
The centre contact of the bulb is a blob of solder, and repeated heating plus the pressure of the socket's centre contact flattens it into a shallow dish. A dished contact touches on its rim rather than its face, which is a small area and a poor joint. You can see it by looking at the base: a clean dome is fine, a flattened or blackened dish is not. If the flicker followed the bulb, this is why — and the honest repair is a new bulb rather than trying to build the solder back up.
And the case that is not a fault at all: an LED lamp on a dimmer. An LED draws a fraction of what the dimmer was designed for, so it may never reach the minimum load the dimmer needs to switch cleanly; and if the dimmer is an older leading-edge type it chops the supply in a way many LED drivers cannot smooth out. That flicker is worst at low settings and disappears at full — which is the signature, and no amount of screwing the bulb in tighter will change it.