Paul confronted Peter publicly because Peter was at fault and needed to be corrected.
Watch the Teaching: Why Paul Confronted Peter to His Face — Galatians Chapter 2