This is my take on why USA hit Iran:
Iran saw that they had no airforce or SAM & Israel could hit them at will. Most of Iranian military leaders were eliminated. Most of Iranian nuclear centrifuges would have been destroyed due to direct hits or electrical disruptions. Even fordow could have been hit repeatedly at the entrance and power supplies to disable it. Iranian regime leadership were also exposed in the open with no defence. Iran could lob few missiles but Israel will intercept most with its air defence and its military targets are unlikely to be hit too hard. Iran also lack key satellite targeting data that Israel has & can't have as accurate strikes. There was no way they could come out of it winning.
So, a ceasefire had to be reached. But Iran could never seen to be surrendering to Israel and abandoning their nuclear program under Israeli threat as that would send it to diplomatic irrelevance. So, the best option was to ask USA to do a predecided strike on its nuclear facilities, thereby showing that it had no choice but to close down its nuclear program as all its facilities were destroyed. Also it gives an appearance to be surrendering against USA, a superpower, instead of Israel, a tiny country.
So, USA striking Iran was likely a joint decision under Iranian request so as to arrive at a ceasefire with greater dignity while giving a valid excuse for abandoning nuclear program.