It’s not the material that’s changing. If you click on the icon in the upper right with the square with 4 tiny squares, one of which is filled in (Mesh Edit Mode Overlays), under Shading, Retopogy is checked. If you uncheck that, the material colors will return.