Basically born with powers (it is revealed in the second one that the mother had powers too) and she accidentally hurt Ana with these powers as a kid. So, the parents panicked and tried to keep the girls seperate in the castle growing up. The parents died at sea before Elsa could learn how to control her winter powers so she had to step up as Queen. Basically, shunned and locked away for her entire life because she was different and viewed as a monster. Just like I was.