If it 'wasn't a mistake' what reason would they have to attack the nation that pretty much makes sure they exist
Most likely because
Liberty was a communications surveillance vessel whose intercepts flatly contradicted Israel's claim, made at the war's beginning on 5 June, that Egypt had attacked Israel, and that Israel's massive air assault on three Arab nations was in retaliation. In fact, Israel began the war by a devastating, Pearl-Harbor style surprise attack that caught the Arabs in bed and destroyed their entire air forces. Moishe Dyan didn't want this information revealed. He intended to sink the Liberty and blame it on the Egyptians, but he failed after a sustained two hour attack in which he killed 34 American sailors and wounded 170 more.
Israel was also preparing to attack Syria to seize its strategic Golan Heights. Washington warned Israel not to invade Syria, which had remained inactive while Israel fought Egypt. James Bamford, in his excellent investigation of this incident,
Body of Secrets, (available from Amazon) says Israel's offensive against Syria was abruptly postponed when 'Liberty' appeared off Sinai, then launched once it was knocked out of action.
Israel's claim that Syria had attacked first could have been disproved by 'Liberty.' (That according to statement by Lt. James Ennes, who was on the Liberty and tells the whole story in his book,
Assault on The Liberty (also available from Amazon).
Most significant, 'Liberty's' intercepts would have shown that Israel seized upon sharply rising Arab-Israeli tensions in May-June 1967 to launch a long-planned war to invade and annex the West Bank, Jerusalem, Golan and Sinai.
You should understand that there never has been a formal investigation of this act of war on the U.S. by a supposed ally. That should tell you something.