There was no end goal. It’s was a militant group who got too much power than it knew what to do with.
Hamas was never going to overpower Israel, the point was to have enough power to prevent Israel from annexing Gaza like they are doing West Bank. Hamas was the first time that Palestinians weren’t weak like the 90’s when they threw stones at tanks.
People forget that Hamas fought Israel to multiple short ceasefire battles in the years leading up to the October attacks. But it seems that confidence lead way to delusions rather than pragmatic thinking.
That defeat was their own fault. They had tens of thousands of rockets and indigenous arms industry to make anti tank rockets and rockets inside Gaza. They had built deterrence from Israeli offensives, that’s not the same as meaning you can go take on Israel head to head or do offensive tactics.
But Sinwar and co were either infiltrated by Mossad who fed them this idiotic idea or were just idiots who couldn’t be content with the power they had and thought one big battle could turn the entire fortunes around. They likely thought having 100+ hostages would give them tremendous bargaining power. I don’t know. Either way they were idiots and got Gaza leveled.