Just because two things are expressed as a proportion of the GDP, they can be very different, e.g., I can express my salary in terms of my country's GDP, but clearly this is different from the debt to GDP ratio.
Deficit vs. debt
If I make less money in a month than I spend, I have a deficit for that month. This does not necessarily mean that I will be in debt - perhaps I had savings to rely on. The opposite is also possible: perhaps I had a surplus this month, and I used it to pay part of a debt that I owe.
Countries are not people, but the logic is pretty much the same. Current debt is kind of like the future value of past deficit/surplus cashflows.