How Steam levels and XP actually work
Your Steam level is a profile number driven entirely by XP, and almost all of that XP comes from badges. A badge is created by collecting a complete set of a game’s trading cards and pressing craft. Crafting is one-way: the cards are consumed and you receive 100 XP, a random emoticon, a random profile background and a discount coupon.
The reason levelling gets slower is that Steam raises the badge cost every ten levels. The first ten levels cost one badge each, so 100 XP per level. Levels 11 through 20 cost two badges (200 XP) per level, levels 21 through 30 cost three, and the pattern continues indefinitely. Getting from level 0 to level 10 is ten badges; getting from 40 to 50 is fifty. That is why the calculator above asks for both numbers instead of just your target — the answer depends on where you start.
Where the badges come from
Every badge needs a full card set, and there are only two ways to get one. You can farm the cards yourself by playing (or idling) games you own that support Steam Trading Cards, or you can buy the missing cards on the Community Market. Steam deliberately grants you only part of a set through playtime — usually around half — so the last few cards almost always come from trading or buying. Free-to-play titles behave differently again: they grant drops in proportion to money spent inside the game rather than time played.
There are also badges that have nothing to do with cards. Community badges, event badges, the Years of Service badge and Steam Awards voting badges all award XP, and some award more than 100. They are one-offs though, so they are useful for a small head start rather than a plan. The calculator counts only craftable card badges, which is the repeatable route.
Foils, duplicates and cost control
Foil cards drop rarely but craft into a separate foil badge worth another 100 XP, so a game you have already badged can still give you more XP later. Duplicate normal cards are worth nothing toward a badge, which is why most people sell duplicates on the Market and use the wallet balance to complete other sets. Buying whole sets tends to be cheapest for older games with large player counts, because supply is high and prices settle near the Market minimum.
If you would rather farm than buy, run the idle time calculator to see how many hours the drops still sitting in your library are worth, or read how to level up Steam fast for the full strategy.