Gaffy, the disappearing and reappearing O and Mac come from part of Ireland's grim history before independence. In the 16th/17th century, people with 'Mac' or 'O' in their surname – in other words, native Irish – were barred from Dublin unless they had a pass to work in the city. The various later laws aiming to wipe out Catholicism and native culture, and the customs attaching to them, also targeted the Macs and Os. By the late 18th century, a lot of Irish families in the Anglosphere had dropped the Mac and O part of their name, so O'Briens became Briens, MacCarthys became Carthys and so on.
A workaround appeared for Macs: a name like MacCarthy would be written as M'Carthy in a kind of nominative bowdlerism.
In the early 20th centuries there was a great reclamation of names, where people re-glued the Mac or O to their surname; some who still had the Mac but spelled in a way considered more Scottish, as Mc, changed the name back to Mac. Sometimes you'd have parents who were Mc and the next generation were Mac. Sometimes just one of a family used Mac and the rest Mac, or vice versa.
And as the Irish language became more important, some used this version of their name, so a Carthy would be come Mac Carthaigh, or in the case of a woman Ní Charthaigh, or for a married woman who had been called Mrs Jane Carthy, Sinéad Bean Mhic Charthaigh…
Using the Irish-language version of the name became more unusual during and after the Civil War of 1922-23, when cynicism about the language spread in that cruel regime…