Most countries just choose not to do this. They weren't forced to default. They could have chosen to monetize their debt. They just didn't choose to do that.
A sovereign could choose to default even if they somehow had a net surplus. Because, you know, sovereign literally means you can do whatever you want up to some more powerful foreign sovereign invading, because you have a local monopoly on violence.