Let me explain the whole system. While playing, you may have noticed when you press the M page, you get a screen showing your class. You can edit your loadout here. Showing every weapon you have for the class you are playing. Pressing the back button shows all nine classes and clicking on a picture of one will move you to the same screen for that class. You will notice below the class selection on your loadout changer is the backpack. This contains every item you have gained during play. You can click on them and delete if you want to. But be sure you have what you want to delete. You can drag and rearrange each weapon to how you like.
There are currently two methods to gain items. One is through achievements, the slightly harder but faster and ensured way. Only weapons can be gained through these achievements and only the class you have gained the milestones on will give them to you. Currently these classes are the Spy, Sniper, Scout, Medic, Heavy, and Pyro. To complete an achievement, you must find one you wish to do, and fufill each objective it says. Some of them are hard and can usually only be obtained though luck, time or farming. Others are easier and can be done via normal play. An example of the latter is the spy and sniper achievements.
The other method of gaining an item is though a random drop system brought by the Steam cloud server. You must be logged into friends to get items this way. During the spy & sniper update, they decided to have a new method of gaining items. It is easier but can take ages to get all the ones you want. All you have to do is go to a server and play as you normally do. Every 25 minutes a random "die" is rolled. This determines if you have gained an item. You have a 1 in 4 chance of getting one an hour. After you have gotten an item, it rolls again to see if it is a rare or non rare item. Non rare items are anything that can be gained via achievements. So they are weapons. Rare items are those which can only be gained via the random drops. After this roll, a last roll is done to determine which item you have gained. To be specific about rare items. You have a .45% chance of getting a hat. To get any 1 hat, you have a .05% chance of getting it.Really, there is no action in doing this. You just get a message in the chat and during your first death after the message, a screen will pop up showing what you got and asking you if you want to ignore any action, equipting it, or deleteing it.