Spellcasting can be quite complicated when first approached, but it can be broken down into simple steps.
Spell splots and spell levels
Firstly, each caster has a certain amount of spell slots, depending on their class and level. You can find spell slot amounts on the class pages of the Player’s Handbook (PHB), and for multicasting, the rules can be found in the multiclassing section of the PHB on page 165.
You then have your spells, each of a level between 0 (cantrips) and 9. Depending on your class and spellcasting ability modifier, you can prepare a certain number of spells to have access to during that particular day (you can change out your prepared spells at the end of a long rest).
I like to envision a character’s spell slots of buckets, each of a different size getting larger as the level of the spell slot increases. The spells can then be seen as balls of varying sizes in a similar fashion. When you cast a spell, you have to put it in a spell slot that is at least equal to the spell’s level, or higher. This means you can’t put one of the balls into a bucket that is smaller than it, but you can put it in one that is the same size or larger. Sometimes you can get a bonus if you ‘upcast’ a spell, that is to put the ball in a larger bucket. These bonuses can range from extra damage, duration, or number of targets.
Cantrips can be cast without limitation (i.e. an infinite number of cantrip buckets), but they cannot be upcast for extra benefits. Instead these increase in effectiveness as a character gains levels.
These spell slots then fully refresh at the end of a long rest.
Warlock spell slots
Warlocks act a little differently, with only a few spell slots, all of the same level (refer to the Warlock class section to see the scaling). When a Warlock casts any levelled spell, it will automatically upcast to the level of the Warlock’s spell slots. For example, a level 5 Warlock has two spell slots each of level 3. So casting any spell, such as Hex, would automatically cast at level three.
To compensate for the lower number of slots, a Warlock refreshes all spell slots after a short rest, as well as the end of a long rest.