Mario-Bowser Fusion

The Mario-Bowser Fusion is an anomaly seen in the Bowser boss battles in Super Mario 64, most commonly found in the final boss battle. The anomaly itself swaps Bowser's upper part of his head with the head of Mario, albeit the Mario head does not have a cap on him. Other than the swap of model parts, voice clips of Mario have been reported to replace some of Bowser's voice clips.

The anomaly is a visual and audio error in the game that hasn't been known how to be triggered. There aren't any signs of malicious side effects of the anomaly, so it can be seen as a benign one. The anomaly's purpose is unknown, but it is most likely related to the Personalisation A.I.

Theories
One theory regarding the visual and audio error and how it might have been caused could be related to The Self-Patching Anomaly. This anomaly, although used for patching out glitches and bugs in Super Mario 64, can have the opposite side effect when the Personalisation A.I malfunctions. One of these results could be the Mario-Bowser fusion as it could've been a result of a corruption in the code by the Self-Patching Anomaly.

Another theory could be that this would have been done naturally, and would've been a result of certain inputs being put into the controller of the Nintendo 64, just like how other personalisation features had came around. How this process is done specifically is unknown, but it could have something to do with going into the Bowser boss fights early if the theory's true. With this in mind, it could also be a check by the Self-Patching Anomaly to check for irregular star counts when Mario goes into the Bowser courses.

As to why Mario and Bowser in specific, it is considered to be as a result of the only entities in these areas of the game being the two characters when the anomaly appears. Bowser's lower jaw being visible could be because the lower jaw itself is a separate segment of Bowser's head, and Mario's head only has one segment.

Trivia

 * Coincedentally, the laughing voice clip for Bowser (and the Boos) was a stock sound effect done by Charles Martinet, the voice actor for Mario in Super Mario 64 (and present).