It is #2. An explanation of the concepts involved will hopefully make this clearer.
ESTA stands for "Electronic System for Travel Authorization." It is not a visa, but is rather a system that screens people who seek to travel under the Visa Waiver Program to ensure they are eligible. The actual program under which you enter the United States after receiving an ESTA is the Visa Waiver Program (VWP), which allows eligible citizens of certain countries to stay in the US for up to 90 days for business or pleasure without a visa.
So, what's going on? The Visa Waiver Program came first, and that's the actual set of rules under which you enter the United States. It allows for stays up to 90 days (with the important caveat that trips to Canada, Mexico, and "adjacent islands" don't reset the clock). As we discuss in How soon can I re-enter the USA having stayed for 90 days under the Visa Waiver Program?, you can make as many such trips as you want, as long as they are consistent with a permissible purpose and you don't cause the officer to think you're trying to live here (spending more time in the US than you do outside would be a large red flag that would get you more questions, for instance). That's a VWP rule and has nothing to do with ESTA.
ESTA is an additional layer on top of that, which was added much later. It requires you fill out the form online, pay the fee, and be approved before you can travel to the US by air or sea under the VWP. Think of it as a security check that ensures you aren't on any watchlists and haven't done anything that would make you likely to be sent back if you try to enter the United States. The ESTA rules say that this approval is valid for two years (unless one of the below circumstances happen, at which point you must reapply sooner). It is still valid for two years no matter how long you spend in the United States during that time. ESTA wasn't added to limit how long you can spend in the US, but rather to ensure that you are vetted more thoroughly before you arrive.
So in summary, you've got ESTA, which lasts two years, and the Visa Waiver Program, which allows visits up to 90 days at a time (subject to being "reasonable"). Spending more time in the US doesn't cause your ESTA to expire any quicker.
The information on the ESTA help page under "What is the Electronic System for Travel Authorization (ESTA)?" helps make this more clear:
Approved ESTA applications are valid for a period of two years, or
until the passport expires, whichever comes first, and multiple trips
to the United States without the traveler having to re-apply for
another ESTA. When traveling to the U.S. with the approved ESTA, you
may only stay for up to 90 days at a time - and there should be a
reasonable amount of time between visits so that the CBP Officer does
not think you are trying to live here. There is no set requirement for
how long you must wait between visits.
Travelers whose ESTA applications are approved, but whose passports
will expire in less than two years, will receive an ESTA valid until
the passport's expiration date.
A new ESTA authorization is required if:
- You are issued a new passport,
- You change your name (first and/or last)
- You change your gender (ESTA does not currently have a gender X to choose from on the application. It is suggested that the traveler choose whichever choice they feel most comfortable with. ESTA will not be denied solely on the gender chosen on the application.)
- Your country of citizenship changes
- Your circumstances change, e.g., you are convicted of a crime of moral turpitude or you develop a contagious disease. Such a change may
require you to get a visa to travel to the U.S. You must re-apply and
your application must reflect the change in your circumstances or you
may be denied entry upon arrival in the United States. More
information about other ineligibilities can be found on the U.S. State
DHS recommends that you apply for ESTA authorization as soon as you
know you will be traveling to the United States under the VWP. If your
ESTA expires while in the U.S., it will not affect your departure.
See also this page from US Customs and Border Protection, which says much the same thing, though it is easier to link directly.
If you're unsure, you can always choose "Check ESTA Status" on the official ESTA website (be on the lookout for scams and imposters) to verify that your ESTA is still valid.