Am I correct in thinking that hotels give cheaper prices if you book last-minute so that they are not "stuck" with empty rooms (during periods they don't have to many guests and a lot of free rooms available)?
If you're using a booking engine such as booking.com, the rule of thumb says that the earlier the better, while it's possible that later on some hotels will offer campaign prices, or as you mentioned, you might catch some last-minute deals. Those are exceptions though, you should not hope for a significant save over a reservation booked well in advance. My suggestion is, in case you're certain about the travel dates, make your reservations as early as possible on the options with free cancellation, then later on check the website regularly to see whether it'd be beneficial to change your reservation. Mostly though, this will not result in a significant financial gain, rather finding better or more suitable hotels in the same price range.
The bigger online hotel booking sites (booking.com, agoda, hotels.com, etc) have a room block with each of their hotels, ie 4, 8, XX rooms held every night of the year. And when they accept your booking they assign one of those blocked rooms.
Depending on their contract with the hotel, they maybe required to pay for all those rooms even if they don't sell them. In these situations, they would discount the room at the last minute as some money is better than none.
But there is no guarantee there will be rooms available for this, so by waiting you risk having nothing.
Going direct to the hotel might find a last minute booking, but that is also not a sure thing. If the hotel has really low occupancy, they might try to discount and fill the rooms, but if they are moderately full they are not as motivated to sell at a loss.