Here is a basic K-mount lens, with the aperture lever at the top:
The original design of the K-mount camera has a corresponding actuator to move the aperture lever like a light switch, just on (stopped down to the aperture selected on the lens's ring) and off (aperture fully open for focusing). At the bottom of the lens photo, there's a rectangular tab that moves in a slot, changing position along with the aperture ring setting. The camera had an aperture follower to track this tab, and tell the light meter where the user set the aperture ring. The system allowed metering at any aperture setting and wide open focusing. That's in about 1975.
When camera makers wanted to add automatic modes, they needed a way to tell the camera more information about the lens, and control it more precisely. Pentax made a couple of changes to their mount, adding electrical contacts for lens information, and making the aperture lever move much more precisely. Now the camera could tell what a newer lens was capable of, and control it. Meanwhile, older lenses would still work the old way, and if you were used to using an aperture ring, you could. That's in about 1983.
About 10 years later, Pentax started eliminating the aperture follower from some cameras. Those cameras required a lens with an A position on the ring. Then 10 more years later, they introduced their first DSLR. Without checking my facts, I think the *ist D didn't originally have stop-down metering - it was activated with a firmware upgrade. This solution meant the camera didn't need any lens information. It just stopped down the lens and activated the light meter.