No, Magic Guard does not prevent the effects of confusion.
Damage from confusion still occurs.
Only Own Tempo exclusively prevents confusion as an ability. Any Pokemon that's confused only has a chance of hitting itself, so you were just lucky not to have a Pokemon with Magic Guard hit itself when confused.
Bulbapedia lists what Magic Guard prevents.