Tosafos in Shabbos 94a defines the concept of מלאכה הצריכה לגופה to be that a melacha must be done for the same purpose that it was done in the mishkan to qualify as a מלאכת מחשבת to be chayev. Other rishonim (Ritva, Ramban) don't mention the clause of doing it for the purpose that it was done in the mishkan, but rather require that one intends to benefit from the primary purpose of the melacha, not just as secondary outcome.
However, Rashi (zevachim 92a) seems to define it very differently. Rashi seems to say that since one would have preferred to never have been in a situation where they would need to do this melacha, such as extinguishing to avoid damage, it is considered a מלאכה שא"צ לגופה. Rashi's language is דהלואי שלא בא עליו. Rashi in Shabbos 63b takes a similar approach in defining the concept of מלאכה שא"צ לגופה and writes כל מלאכה שא"צ לגופה אלא לסלקה מעליו הוי מלאכה שא"צ לגופה דברצונו לא באה לו ולא היה צריך לה הלכך לאו מלאכת מחשבת היא לר
Rashi seems to hold that anytime one would have preferred to have never entered a situation where they would have to do the melacha, it would qualify as a מלאכה שא"צ לגופה. See Tosafos in Shabbos who raises this point and considers Rashi's definition to be quite strange.