There are many ways to get new weapons. TL;DR: the most effective is trading with other players, but read below.
Some very potent class weapons one can get by making 5, 11 and 17 or 10, 16 and 22 class-related achievements, the amount depends on the class, each milestone giving a class weapon. The weapons will be usable in crafting, but not tradable. Many achievements are pretty easy to get by just playing the class normally.
Without actually having some of those weapons, gaming can be hard and unpleasurable, but you will get them inevitably if you just play the class normally.
Each 30 to 70 minutes of playing the game (random, average 50 minutes) you are guaranteed to find one item, usually a weapon. You have to click to accept the item before you can get a new one, so idling hardly helps, no more than 10 hours per week per account count (average maximum of 12 weapons per week).
This is a steady way to get new weapons, but you will find a lot of duplicates, and it really, really takes time. Certainly not a fast way to get new weapons.
Anyway, players have accumulated a lot of random drops since they were implemented in the Sniper vs. Spy Update (May 21, 2009), and it makes most ways of obtaining weapons besides trading no longer worth it. Again, read below.
For a new player Mann vs. Machine mode is a good way to polish some skills, and you also get random drops as in normal game. You may play on community servers, or on official — in the latter case you have to pay money for each game you complete, having a Tour of Duty Ticket in your inventory. When you win a mission, you are guaranteed to get one random item, and the ticket will be consumed. A ticket costs ~$1. Each player may also present a Squad Surplus Voucher, which costs ~$2 and gives an additional random drop to each party member. If you are playing in a party of 6 friends (which is more fun than playing with random guys IMO), and each of you presents a Squad Surplus Voucher, then each of you gets 7 random drops for $3, or each item per $0.43. That can be fast, but not really an effective way of investing money in TF2.
Keep in mind, though, that you have a chance to get unusual items that are worth more than normal weapons, so it doesn’t mean that you shouldn’t play MvM to grind items.
With many attempts and trading you might actually win more than you invest, but I didn't do the math so currently I advise against this method.
To open a crate you need to buy a Key which costs $2.50. You can get some pretty amazing stuff from a crate, but it would take a long time, a lot of keys and crates to get the weapons you need. Don’t do it unless you are willing to invest some keys and then trade things that you get. Actually, buying keys to open crates is akin to gambling.
Plus, you will likely lose the competition to those who buy keys using stolen credit cards for money laundering...
Just buy the weapons from the Mann Co. Store
Yes, you can buy them straight away, if you read an article about any weapon in the game, you will notice that there’s a price for most of them. But that’s very, very ineffective money-wise. Don’t do that -- I was silly enough to do it multiple times in the past, and I could get a lot more for that money.
Instead of buying a weapon, you can always choose a test run and get one single weapon for 7 days. The item will be non-craftable and non-tradable, and you can only have one item for a test run at a time. When those 7 days end, the item fades, and you may select a new one for a test run, probably even the same item. However, before they end, you cannot select another one.
This is a good way of actually trying something out and/or compensating for not having an item. Was even better when a test run length was 2 days back in the day...
By salvaging duplicate weapons you may obtain new ones. However, that’s not the most effective way of getting rid of duplicates, read below about trading. The point is that costs of crafting most weapons are higher than what they are actually worth. Items that are worth crafting exist, but they are not standard weapons, they are mostly cosmetics.
The cost of crafting a new weapon is up to 37 standard weps, in most cases it’s around 7-13. Trading is much more effective.
You may exchange different items with other players.
Ask a fellow veteran player for help
If you have a friend who plays TF2 for long, he most likely has a lot of duplicate items in his inventory that aren’t really needed. You may ask him to give you some for free.
Exchange 1:1 with your friends
If you have friends who play TF2 and don't have all the weapons yet, you can exchange duplicate or otherwise unneeded items. You may expect 1:1 ratio, and it’s good.
Use a trading website to trade weapons 2:1 or one scrap metal per weapon
By smelting 2 class weapons you may get 1 scrap metal for further use in crafting.
If you go to a trading website, you will see plenty of offers to trade two of your craftable weapons or 1 piece of scrap metal for any trader’s weapon. Your benefit is getting a desired weapon, trader’s benefit is getting more scrap metal for crafting hats.
3 pieces of scrap metal form 1 piece of reclaimed metal, and 3 units of reclaimed metal can be turned into 1 piece of refined metal.
You might find more information about trading and finding trade partners in a related question "How do I determine what my TF2 items are worth?", particularly in the accepted answer by @badp. Keep in mind, though, that prices have changed significantly since then!
A key, if you choose to sell it, costs around 26-27 pieces of refined metal, which can be turned into 26*9=234 pieces of scrap metal, each traded for one normal weapon. Again, prices could change by the moment you read this! Don't forget to recheck!
This is the most effective way to inject money in TF2 economy to get weapons.
My rough calculations using the MANN CO. CATALOG have shown that there are about 170 weapons in this game, barring those that are just normal weapons with some quality added. It means that for just one key you can get every single weapon feature in this game besides cosmetics. Moreover, some of those ~170 are useless crap, some are reskins of others, so you will actually have some metal left for buying cosmetics and probably sharing some weapons with your friends. You can actually arm a bunch of full MvM squads this way!
I would suggest you to sell the key for refined metal, and then trade this metal for weapons, as expected seller is unlikely to have a duplicate of every single weapon in the game just for you, plus you will need a lot of change anyway. :)
Buying weapons this way costs ~$0.01 per wep -- compare to buying each weapon for $1-2 from the Store or getting them for ~$0.43 to $1 from MvM.
Remember that trading only becomes available when you make at least one purchase in the Mann Co. Store, so I strongly suggest the key as that purchase.
Trade Holds: A very important note on trading
- If you and your trading partner were Steam friends for the last year, or you both have your Steam Guard Mobile Authenticator enabled, trading happens instantly. That's fast, isn't it?
- If you are friends, but for less than a year, and Steam Guard Mobile Authenticator is not on for any of you two, trades are put on hold for 3 days. It means that you will only get your items after the time passes.
- If you are not friends, trades are put on hold for whole 15 days! That's a lot of time.
Keep the holds in mind when trading. To avoid frustration from having to wait, enable Steam Guard Mobile Authenticator or at least friend each other.
Steam Guard Mobile Authenticator also does a good job protecting your account as a bonus. :)