Someone asked me this question today and I didn't really know how to answer the question. When something is last, the definite article should precede it because there's only one last place.
If you Google the phrase you'll find at least a couple of dictionaries that define "as a last resort" "as the last choice," while others offer "in the last resort" as an alternative phrase. Thus, I believe it is simply an idiom in widespread use, and there is no sound grammatical reason to use the indefinite article.
The question said:
When something is last, the definite article should precede it because there's only one last place.
But that's not the case here.
These are hypotheticals, as they have not yet happened. So there can be more than one possible last resort.
If you have a choice of mutually exclusive last resorts, then each is a last resort, while still being last. This will be the case if only one of a choice of last resorts is possible.
- As a last resort you could scuttle the ship by firing the magazine.
- Or you could ram the enemy
- Or you could surrender
But you cannot do all three as they exclude each other, so any will be the last resort if it is used, but whilst under consideration, each is a last resort.
Adding to Mark Hubbard's great answer, if there were numerous resorts that were used before the last resort, it would be correct to use as the last resort. The noun resort is a mass noun that takes an indefinite article only when it is used to mean:
A course of action that is resorted to: 'her only resort is a private operation. 'Surgery is a last resort, though it sometimes is necessary'
The second example sentence didn't use the definite article the. It is obvious that the noun resort is something that you "turn to and adopt (a course of action, especially an extreme or undesirable one) so as to resolve a difficult situation".
You don't resort to multiple resorts (extreme or undesirable courses of action). You resort to only one resort.
The indefinite article a in the idiom means one single:
As one single last resort, she decided to undergo surgery.
The adjective last usually requires the definite article, but there is an exception when it doesn't mean:
Coming after all others in time or order, final: 'they caught the last bus'.
A resort doesn't come after another resort and is not final. That's why the definite article is not necessary.
If you compare the idiom with as the last choice, the distinction would be clearer. You had multiple choices before you take the last choice, but you didn't have multiple resorts before you take a last resort.
Note: This is a broadly used idiom and sometimes an idiom can't be explained using a grammatical rule or dictionary definition. As some commented, it is as idiomatic as in the last resort and as the last resort and why one idiom uses a and the other the is difficult to explain.
Even thought the linked Ngram Viewer for "suicide as a last resort" and "suicide as the last resort" shows only "suicide as a last resort", if you Google them, you get 12,800 hits for the former and 28,000 hits for the latter.
[Oxford Online Dictionary]
"Last resort" refers to a course of action taken when all others fail or no others are available. "Last" in this circumstance refers to something along the lines of "this will definitely work, but may have bad side-effects," "if this doesn't work, nothing will," or "once we try this, we won't be able to try anything else." It implies a lack of desirability in the option. "Last resort" thus doesn't refer to a particular action, but a class of actions. Multiple last resorts for a single problem can exist.