The beginning of Frozen explains that Elsa and Anna are kept in the castle, which makes sense for the former due to her powers, but it's unclear why Anna was also made to stay indoors. As children, the two sisters were very close, and Elsa frequently used her powers (which she could have inherited from Queen Iduna,) to make fun activities in their playtime. In one instance, Elsa is making ice platforms for Anna to jump onto, but Anna keeps getting faster, forcing Elsa to try and keep up with her. Under this stress, Elsa accidentally injures Anna with her powers. Their parents, the King and Queen of Arendelle, take Anna to the magical trolls who heal her but also alter her memories so that she has no knowledge of Elsa's powers. This fright led the King and Queen to isolate both Elsa and Anna from the kingdom.
This isolation resulted in the two sisters being very different from one another in Frozen, and not only because Anna doesn't have powers. Elsa craves to be left alone, confining herself to her room in the castle, whereas Anna only feels extreme excitement regarding being out in the world, and yearns to be close to Elsa. As Anna is such an excitable character, it begs the question of why she had to suffer such loneliness in the castle.
Related: Why Encanto 2 (& Beyond) Is A Better Disney Franchise Than Frozen
It is not explicitly stated in Frozen or Frozen 2 as to why Anna is also kept there, but it can be assumed it was likely to protect her and her sister. After the accident with Elsa's powers, their parents were probably keen to keep an eye on Anna, which they wouldn't be able to do with such a rambunctious child running freely around the kingdom. Thus, unfortunately, Elsa's ice powers rendered her, along with her
Read more on screenrant.com