auf Anhieb
on the first try
Immediately on the first attempt; without difficulty or delay.
Sie hat die schwierige Prüfung auf Anhieb bestanden.
She passed the difficult exam on the first try.

first try
Loading your saved state.
on the first try
Immediately on the first attempt; without difficulty or delay.
Sie hat die schwierige Prüfung auf Anhieb bestanden.
She passed the difficult exam on the first try.

The noun 'Anhieb' is used almost exclusively in the fixed expression 'auf Anhieb' (on the first try/right away). It is not used on its own with an article like 'der Anhieb'.
Es hat nicht auf Anhieb geklappt, aber beim zweiten Mal schon.
It didn't work on the first try, but it did the second time.
The expression can be derived from its parts: 'der Hieb' means 'the blow/strike'. So 'auf Anhieb' literally means 'on the first strike' and figuratively 'on the first attempt'.
Der Sportler schaffte den Rekord gleich auf Anhieb.
The athlete achieved the record right on the first try.
The expression 'auf Anhieb' (on the first try/right away) is often combined with verbs of succeeding or understanding. Typical examples are: 'etwas auf Anhieb schaffen' (to manage something on the first try), 'verstehen' (to understand), 'finden' (to find), or 'klappen' (to work out).
Ich habe die neue Software auf Anhieb verstanden.
I understood the new software right away.
immediate / same
'gleich' and 'auf Anhieb' can both have to do with something immediate. 'gleich' generally means: in a very short time or right away. You can use it in many situations, for example when you are coming right away or calling back right away. 'auf Anhieb' is used only for an attempt or a result. It means that something works or is understood immediately on the first try. So 'gleich' is more about when something happens. 'auf Anhieb' says that something succeeds without several attempts.

Sofia hat die schwere Aufgabe auf Anhieb gelöst.
Sofia solved the difficult task on the first try.
Ich rufe dich gleich nach dem Termin zurück.
I'll call you back right after the appointment.