From the source:
Alphys: “I-I’ve been studying you on your journey. Your AI is amazing! S-sorry, it’s just that I never seen a surface robot up close before. We’ve been reverse engineering your tech to help modernize our underground society! I even tried to recreate advanced AI myself.”
Quote: "That's why I came here. I'm curious about an Underground robot. Mettaton, right? Is he friendly?"
Alphys:"I reversed engineered him from abandoned killer robots."
Quote: "Well, I’m a killer robot as well. "
Alphys: "No, you misunderstood. I gave him a programming to kill all humans or anything guarding said human. But that was before I saw the progress with you and the human you were protecting! But I just couldn’t delete it in time. So now he's an unstoppable killer robot? But don't worry, I can disguise you so you'll look like a robot built from Underground tech!"
Quote: "…How?"
Alphys: "…I heard rectangles are the craze these days."