kenandbarbie the order of succession goes by branch. Precedence within a branch is by age and (until the birth of George but not in effect until Charlotte) by gender. Every time someone "above" you has a child, you're bumped down the list. The point is to preserve the most "direct" line so it runs parent to child as much as possible.
So when when the Queen was a girl she was the heir to the throne when her father became king. Margaret was 2nd in line behind as younger sister and they were one "branch" of the family tree. The younger brothers of their father and their families were different branches, under the Queen and Margaret as they were the kids of the Monarch- most direct. When the Queen had hen the Queen had Charles, he became the heir as the child of the Queen- the most direct route for the crown. Every subsequent child pushed Margaret further down the list for the same reason, and in turn every other branch of the family. Charles having kids displaced Andrew as second in line, William having kids displaced Harry.
Abdication is also done in favour of the next person along. Edward VII abdicated in favour of his next eldest brother because he was childless at the time of the abdication. If the Queen abdicated, Charles would get the throne, if he abdicated it would be William. William would abdicate in favour of George, although if Wills became king next week and abdicated or died, George would require a regent to rule until he was of age. That would be Harry as the next royal adult along although I dare say Kate would play a part. If the Cambridges were wiped out, Harry would be heir again because an entire branch of the tree is gone. You can abdicate & waive your DC right to the throne but that usually happens when countries become republics.
To illustrate the point, UK succession has gone from - Elizabeth, Margaret etc
to Elizabeth Charles Margaret etc
to Elizabeth, Charles, Andrew, Edward Anne Margaret, David Armstrong-Jones etc
to Elizabeth, Charles, William, Harry, Andrew Beatrice, Eugenie, Edward etc
to Elizabeth, Charles, William, George, Charlotte, Louis, Harry, Archie, Andrew, Bea etc.
Until the birth of George, the rules said the oldest boy inherited and placed men above women. Now, it's birth order. So Charlotte would inherit before Louis if George died or abdicated childless. Previously she wouldn't have. See Andrew & Edward bouncing Anne down the order despite being younger.