Expedia buys hotel rooms in bulk from many chains and many individual hotels. They get a good price from the hotel - a really good price - because the hotel gets guaranteed income for that room - and they can pass all or some of that price difference to you - but that means Expedia is on the hook to sell it. Everyone is trying to maximize revenue, and it works out in your favor, because a hotel room night, like an seat on a flight, has to be sold by a deadline or there's no money in it at all.
BTW - they are truly buying rooms in bulk. Significant percentages of available room nights at some hotels. Another answer here is suggesting "If Expedia is e.g. paying the hotel 80€ in any case for a 100€ full price room". My guess is that's not right: You should think wholesale, not retail.
This is called the "merchant model" and Expedia does a lot of it, though I don't think they release their numbers for how much business they do this way vs. other kinds of bookings. This article discusses various business models in the travel business including Expedia's.
On the web you can see financial results from Expedia and analyst reports that suggest Expedia gets a very large percentage of their profit from hotels. They do cars and flights too of course but the profit there is much slimmer - especially for flights which is a totally cutthroat sector. But: people going on a trip usually need flight + hotel or flight + car + hotel. That means there's a lot of ways Expedia can make the whole package be really attractive to you - especially compared to what you get when you shop flight independently from car independently from hotel - while still taking in plenty of money.
Oh, and by the way, Expedia isn't just Expedia.com. Look at wikipedia's article on Expedia Group to see in the first paragraph just a few of their many brands:
Expedia Group is an American global travel technology company. Its websites, which are primarily travel fare aggregators and travel metasearch engines, include CarRentals.com, CheapTickets, Expedia.com, HomeAway, Hotels.com, Hotwire.com, Orbitz, Travelocity, trivago, and Venere.com.
If you rent a hotel room from any of these sites (and several others) it is from Expedia and it is coming out of their inventory of hotel rooms (if it is from a hotel they're buying rooms from).
(Bookings.com is similar: they sell via multiple brands.)
Other answers that point out that you can sometimes get a matching price from a hotel: that's true. And what's also true - in my experience, so anecdotal - is if you book directly with the hotel you can easily get a better room and certainly better service while you're there. So there's some trade-offs there that you can use if you're a more experienced traveler than I am!
(Expedia has sure come a long way since they were a tiny Microsoft product group selling a CD-ROM travel encyclopedia ...)