Rigidity estimates for two wells and applications to thin films