I agree that the quick change in candidate played a big role. We also know now (in hindsight) that no matter how qualified they are, some people will never vote for a female for president. We saw it in some of the interviews with everyday people that they didn't think a woman could handle dealing with other male leaders around the world. I do believe that if Nikki Haley got the Republican nomination and went up against Biden, Biden would of eked out a victory.
I honestly don't think Harris could have done anything more to increase her chances. In 2016 people were talking about how Hillary ignored the battleground states while nearing the end of her campaign. Harris was traveling her ass off.
I think polling inaccuracies had something to do with it as well. They give a false sense of security. Just think about it, every time we hear about a "red wave" in voting, the opposite happens (Democrats have higher turn out). This year, polling data and the general vibe this year was that Harris would win. The result, more Republicans turn out while Dems sat at home.
On a personal note, one of the black females that I supervise (in her late 20s), said that she was not voting when I asked her before the election. When I asked her why, she said that she didn't care for any candidate, nothing is going to change no matter who was in office, and Harris was probably going to win anyway, so her vote wasn't needed. After the election, her response was, "well, she (Harris) won Virginia anyway," so she was right that her vote was not needed. I bet tens of thousands of Americans who sat home had that same sentiment before the election.