Multiphase Polarization in Ion‐Intercalation Nanofilms: General Theory Including Various Surface Effects and Memory Applications