The Queen can’t change laws. Margaret was second in line until EII gave birth to Charles, and moved down as the Queen’s own offspring increased. Margaret remained in the line of succession until her death.
When Margaret wanted to marry her love, Peter Townsend, Elizabeth had an agreement drawn up that required that she give up any right to succession to the throne.