From the Basic Rules, p22 & p30:
The (class) table shows how many spell slots you have
to cast your spells of 1st level and higher. To cast one of
these spells, you must expend a slot of the spell’s level
or higher. You regain all expended spell slots when you
finish a long rest.
You prepare the list of (class) spells that are available
for you to cast from (the cleric spell list / your spellbook). Choose a number of (class)
spells from your spellbook equal to your (spellcasting ability score)
modifier + your (class) level (minimum of one spell). The
spells must be of a level for which you have spell slots.
For example, if you’re a 3rd-level (class), you have
four 1st-level and two 2nd-level spell slots. With a
(spellcasting ability score) of 16, your list of prepared spells can
include six spells of 1st or 2nd level, in any combination,
chosen from your spellbook. If you prepare the 1st-level
spell X, you can cast it using a 1st-level or a
2nd-level slot. Casting the spell doesn’t remove it from
your list of prepared spells.
You can change your list of prepared spells when
you finish a long rest. Preparing a new list of (class)
spells requires time spent (praying/studying): at least 1 minute per spell level
for each spell on your list.
Essentially, 5e wizard/cleric spellcasting is sort of a combination of 3.X prepared & spontaneous spellcasting. If you are familiar with them, the spirit shamans from Complete Divine used an extremely similar system in 3.5, so they would be a good point of comparison. You prepare spells at the start of the day, but this merely determines which spells are available to you to cast that day. You have a certain number of spell slots for casting spells, but you don't choose which spell to use in them until you actually cast that spell. Note that, as in 3.X, wizards choose their spells to prepare from their spellbook, while clerics can choose any spells in the cleric spell list.
For example, a level 1 wizard with an Int of 16 can memorize four 1st level spells and has two 1st level spell slots. Let's say the wizard's spellbook contains burning hands, detect magic, mage armor, magic missile, shield, and sleep. The wizard chooses to prepare burning hands, mage armor, magic missile, and sleep that day. She can use her two spell slots to cast burning hands and mage armor, or sleep and magic missile, or magic missile twice, or any other combination of 2 spells from her prepared spells (duplicates allowed). She doesn't have to decide which of those spells she casts until she actually casts them & expends the spell slot. She couldn't cast shield, however, since she didn't prepare it that day.
Note that unlike 3.X you do not need to prepare/memorize a spell more than once in order to be able to cast it more than once in a given day.
A Brief Addendum on Higher-Level Slots
In 3.X you could prepare a spell in any slot equal to or greater than its level, which didn't offer any particular benefits, but let you cast, for example, a level 1 spell more times than you had level 1 spell slots. In 5e this is fairly similar: you can cast any prepared spell by expending a spell slot of its level or higher. In contrast to 3.X, however, most spells will automatically improve when cast using a spell slot of a higher level than needed. This helps make up for the fact that spells no longer scale with caster level. A magic missile cast from a level 1 spell slot is just as effective for a 1st level character as it is for a 20th level character; if the 20th level character wants their magic missile to be stronger then they need to cast it using a higher level spell slot.
Another Brief Addendum: Rituals
Both clerics and wizards can cast certain spells as rituals (spells that can be cast this way will say so in their description). Doing so increases the casting time to 10 minutes, but does not expend a spell slot the way casting it normally would. Note that wizards can cast any ritual spell in their spellbook this way, whether they prepared it or not, whereas clerics can only cast ritual spells that they have prepared.