William and Harry used Wales as a surname when they were at school/in the army, taken from their Father's title as the Prince of Wales.
When William married he became the Duke of Cambridge, so his children take Cambridge as a surname, because they are titled - HRH and Prince/Princess.
Harry became the Duke of Sussex on marriage, but because of the way the letters patent (and the amendments) are set out, Archie won't become HRH Prince Archie until Charles becomes King.
So because he isn't HRH, he takes the official surname, which is Mountbatten-Windsor; which was decided when the Queen ascended the throne.
The Wessex children are a bit of an anomaly. They are technically HRH, and entitled to be Princess Louise and Prince James, using the last name Wessex as needed. Because The Wessex's chose not to use HRH, they have adopted the use of the Mountbatten-Windsor surname.
We don't see Mountbatten-Windsor used very much so far, because Andrew didn't have a son. If Eugenie had been a boy, then August would have been August Mountbatten-Windsor, rather than August Brooksbank. Same will be true for Beatrice.
If Charles really is planning to amend the letters patent further, meaning Archie and Lili won't become HRH when he ascends the throne, then there's only Archie and James who are likely to carry the surname down the line going forward.
This is assuming that James isn't made a Duke when he marries, which I think is unlikely given Beatrice and Eugenie weren't made Duchesses and Charles is likely to be king before that happens.
I wonder if the plan is still that Edward becomes Duke of Edinburgh in time, and whether that changes the plan for the Wessex children?