Another answerer (Rob Hitchens) has basically hit upon the mechanism in his answer + comments, but I think it's beneficial here to dig into the Compound whitepaper. Although the details of the interest rate models have changed, the high-level concepts still apply to how the CToken functions.
When system parameters change, this will adjust the interest rate, and since it applies to all borrowers, the history of interest rates must be "tracked" somehow.
The whitepaper explains:
The history of each interest rate, for each money market, is captured
by an Interest Rate Index , which is calculated each time an interest
rate changes, resulting from a user minting, redeeming, borrowing,
repaying or liquidating the asset.
In particular, on each transaction, we find that the index is updated, but the accrued interest is also accumulated onto the total borrows and reserves:
Each time a transaction occurs, the Interest Rate Index for the asset
is updated to compound the interest since the prior index, using the
interest for the period, denominated by r * t, calculated using a
per-block interest rate [...]
The market’s total borrowing outstanding is updated to include
interest accrued since the last index [...]
And a portion of the accrued interest is retained (set aside) as
reserves[...]
Then it becomes simple to track how much a borrower owes (including the accrued interest) by taking snapshots of (balance, interest index) whenever the borrower takes an action.
Note that the exchange rate between a CToken and its underlyer token does depend on quantities involving accrued interest.