The short answer
A foreclosure sale exists to satisfy a debt, not to enrich the lender or the county. If the winning bid clears the mortgage balance, unpaid property taxes, and permitted costs, whatever remains is surplus.
That money is deposited with the court or the county treasurer and held. It is not applied to anything else, and it does not automatically find its way to you. A claim has to be filed, in the right form, before the state's deadline passes.
