How does the
TIMER function work in Extended Color BASIC? How does the number keep incrementing even when the computer appears to be doing nothing?
The CoCo has an interrupt called fast interrupt (FIRQ) which is connected to the video output horizontal sync pulse. The IRQ happens every 1/16 of a millisecond (62.5 microseconds). The extended basic command timer uses this interrupt to increment its counter. Remember that the IRQ happens independently of what you see on screen so this is why the number keeps increasing even if "nothing" is happening.
According to this paper from 1987 written by Arthur J. Flexser, the TIMER command of the Extended CoCo BASIC counts "horizontal synchronization pulses, which are approximately 1/16 of a millisecond. This count is multiplied by a constant to convert to milliseconds and is then rounded to the nearest integer."
The document also explains that holding a keyboard key down or keep the joystick button pressed will make the timer to halt, since the TIMER routine first check to see if both of them (key and joystick button) are in released state.