Can someone explain to me programming logic behind multiplexing a LED segment display?
The trick here is that you should not treat each digit as a separate entity.

Basically, multiplexing is a way of sharing a small number of IO pins to control a larger number of physical things, in this case LEDs. This is called time-division multiplexing. Multiplexing is just a way of driving N*M devices with N+M IO pins. 

What you're missing here is that you don't count for each digit internally. Instead, you have a counter that maintains the overall counter value. 

Say the internal counter has a value of 502. First, you illuminate the number 1 digit, with the value 5. Then, you illuminate the number 2 digit, with the value 0, and finally, the number 3 digit with the value 2. There is no incrementing or really any knowledge of what the value 502 even means.

If you want to increment the counter, you have to alter the internal counter number, not anything having to do with the multiplexing system.

For an even more basic implementation, separate the entire concept of numbers from the multiplexing. In this case, you have a array in memory that's just dictates which LEDs in the array are lit. Your multiplexing system just sits there and scans that array, lighting up each part in turn, and nothing else. The code that handles or is even aware that the values in the array represent numbers doesn't know the digits are multiplexed, or even exist. It just knows that this bit means that that LED should be illuminated as it lights up each display segment in turn. 

The code that writes the values into the array is what handles determining what ordering of bits means what digits. 

Critically, the counting and the multiplexing are separate processes. For multiplexing to be effective in a display system, the multiplexing has to run fast (100+ times a second). However, since the code that modifies the array is separate, it can run much more slowly (e.g. at a rate humans can track, etc...).