Theoretically, a DSPs (demand-side platform) buy an ad inventory from Sell Side Platforms.
But an Ad Networks may buy also ad inventory from another network or from a Sell Side Platforms so they can sell it to advertisers at a profit. Ad networks want to sell more ads and if they find what they are looking for at the right price, they will pay for it.
The following entity may buy impression:
Buyer in an auction are called bidder