TL;DR: I declined a job offer under somewhat unique circumstances, HR person called me unprofessional and unethical for rejecting their offer. Was I?
I had changed jobs about 7 months ago. At that time I had interviewed with startup A and startup B. Startup B made me an offer first, so when startup A made an informal offer, I politely declined their offer and joined startup B. I was not given a formal offer letter from startup A, and I never signed anything at this point.
4 months into my new job, I started feeling that it wasn't working out, so I started looking out for another job. After searching for 2 months, I reached out to startup A again, and asked if they were still hiring. When asked why I was changing my mind, I explained it was not working out, so HR said they would check if they had an opening, and came back with a formal offer a week later, with a designation usually given to employees with 4-5 years less experience than me, but I was very desperate. I told them I intend to accept the offer formally by sending them a confirmation email, within a day or two.
I was then contacted by an enterprise company I really wanted to work at. I told the recruiter that I was about to accept an offer with another company, so they sped up the interview process and made me a significantly better offer.
So I told startup A that I found a better offer, and I would not be accepting their offer. I also apologised profusely over phone and over email. But the HR from that startup was really angry at me, and called me unethical and unprofessional, and accused me of "using" their offer to get better offers.
Did I do anything wrong? What constitutes accepting an offer letter? Telling them that I intend to accept the offer in some time, and actually accepting it are two different things, right?
How could I have handled this situation better?