While Toyota was raking in wheelbarrows of easy cash from moneyed buyers Nissan was selling Altimas for bottom dollar to people who were rolling in negative equity from a Dodge Journey.
This is standard BigCo stuff. You get a lead and you lose that lead because you don't jump hard enough onto the next big thing because you don't want to divert resources over the thing you're currently winning with. IBM, Boeing, Ford, Microsoft, they've all been down this road.
Nissan never had that lead so they had nothing to stop them from going into EVs deep enough to grab a good share of the market.