EDIT: I'm describing single winner elections.
Every round, you count one new step of rankings, and eliminate the lowest candidate.
Round one starts with simply counting all 1st rank votes first.
Everybody's vote counts once, to one person. It goes to that voter's highest still-in-the-running candidate.
In the first round, if some candidate already gets 50%, they win directly. If not, you eliminate the person with the lowest votes.
(some variants pre-filter all candidates with too few total votes to have a chance, especially people who didn't even get ranked by most, or only low ranks)
What happens now is that people whose 1st vote was for the eliminated person gets redirected to their next highest person still in the running for the next round on the ballot which they cast. So in round 2 that's your rank 2 on your ballot. Each remaining candidate now has their 1st rank votes from round 1 plus also their 2nd rank votes from all ballots which had been cast to the now-eliminated candidate.
Note that in each consecutive round, all votes which was already counted to a person who still in the running in that round remains untouched. So all who picked a 1st which is still in are still getting counted to that person. You don't look at your 2nd rank yet if your 1st is still active.
So now in round 2, after the redirection to second choices, if that puts somebody over 50% they win. If not you eliminate yet another person, the lowest one every time. Every vote counted to that eliminated person, either 1st's or 2nd's, now gets redistributed again to that voter's next highest person still in the running on their cast ballot - if your 1st is eliminated now, it goes to the 2nd if that person still is in, if not it goes to your 3rd. If you were already on your 2nd and that person is eliminated, it also goes to your 3rd. If somebody's 1st and 2nd are eliminated AND they don't have a 3rd, their vote gets ignored in the rest of the tallying process.
In round 3 and on you just keep going, until somebody gets 50% or all but one is eliminated. You may force a revote in many places if that person is beneath some threshold.