There is clearly a prefix in names like McDonald, McChrystal, O’Brian, O’Neal.
What does this Mc- and O- prefix signify? It looks like Donald, Chrystal, Brian, Neal are perfectly fine names on their own, so why is there a prefix before it?
The standard way to form a name using a simple patronymic byname for men is:
The standard way to form a name using an Irish clan affiliation byname for men is:
Two common misconceptions are (1) that Mac means "son of" — it actually means just "son", and the "of" comes from putting the father's name into the possessive case; and (2) that Mc is Irish while Mac is Scottish (or vice versa) — actually, Mc and Mac are two ways to write the same thing, and both occur in names from both countries. (What is true is that O' is almost exclusively Irish; despite the romantic notions we have of Scottish clans, they didn't use their clan affiliation in their names.)
Edit: as for why the prefix is used even though the prefix-less names look perfectly fine on their own, this is basically Gaelic grammar and thus out of scope for this site. Suffice it to say, some languages are fine with unmarked patronymics — names that identify the bearer's father using the unmodified given name — but Gaelic is not one of them.
I found the following quote which could be helpful. It is from David Booth's (1766-1846) book: An Analytical Dictionary of the English Language.
"Words in ITE very generally denote one of a tribe or nation, and as such may be taken substantively, and have the plural. The Old Testament is full of such denominations, such as the Hittites, the Midianites, &c. Like the ides of Homer, they bore the name of their ancestor. The Israelites were the children of Israel, as the Danaides were of Danaus ; in the same manner as the MAC (son) of the Irish, refers to the father of the tribe, to whose name the syllable is prefixed. Such PATRONYMICS (father-names), as they are called, exist among all nations."
Page xcvii (or pdf page 113) Source: https://archive.org/details/analyticaldictio00bootuoft
Mac, is the Gaelic for "son", and O' means "grandson of". It is found mainly in names from family of Irish origin.
See Wikipedia for more information.