Many of the surviving Scandinavian languages have palatalised g in similar environments, but loan words like give (which replaced the native word, which gave dialectal yive) show that at the point of borrowing, Old English must have already palatalised these g's, and Old Norse cannot have done so.
It's worth noting that standard textbook Old Norse is actually the Old Icelandic of the the Sagas, and dates to around the 13th-14th centuries; after the end of the Old English period, and several centuries the period of most intense contact in the Danelaw in the 9th-10th centuries. It is also this earlier period that standard textbook Old English dates to, mostly being based on texts produced in the West Saxon dialect during the reign of Alfred the Great and his immediate descendants.
Even the First Grammatical Treatise, our earliest description of Old Norse phonology, describes an archaic phonological system very different from textbook Old Norse (especially the presence of nasal vowels) and dates to the 12th century, well after the period of most intense contact, and does not appear to show palatalisation of g in these environments.
It should also be noted that, whilst most modern Scandinavian languages have palatalised g in some form or another, the reflexes of the initial g in Old Norse gefa vary between [ɡ̊] (Danish), [c] (Icelandic), [t͡ʃ] (Faroese), and [j] (Swedish and Norwegian), and with the exception of Swedish and Norwegian these are all still phonemically /g/. From this evidence we would probably reconstruct Proto-North-Germanic* to have had /g/ here.
So the early Old Danish spoken in the Danelaw almost certainly did not palatalise g in environments like this, and the two developments must have occurred in very different eras (before the 9th century in Old English, and various points after the 12th in Old Norse, and even then possibly not in all dialects).
So why did they both palatalise?
Because this an extremely common sound change cross-linguistically. It's the cause of "hard" and "soft" c & g in the Romance languages (apart from Sardinian), and numerous consonant alternations in the Slavic languages stemming from the Slavic First & Second Palatalisations.