Typically, there is a series of fees associated, and you often only see the total, so it is hard to compare.
- the owner of the ATM might charge a fee
- the owner of the location might charge a fee
- the company maintaining (restocking) the ATM might charge a fee
- the bank whos name is on it might take a fee
- your bank might take a fee
- any intermediate bank that connects your bank with the bank in the foreign country might take a fee
- one of the 2+ banks does the actual currency conversion, and although they typically use the interbank exchange rate, they add a fee too; typically as a percentage
As said, some of the fees are 'merged' into the rate, so you don't see them (and there is a little sticker on the ATM [probably in 4pt-font and under the bottom of the machine], that informs you about it).
Your best chance is with ATMs inside banks, with large international bank, or ATMs from banks associated with your bank; that removes many of the potential fees.
Buying currency is not that cheap either, because it requires for a US bank to have Euros, or for a European bank to have US dollar; both of which is effort and they will therefore take a fee, oftne rather higher than ATMs.
Worst possibility is exchanging in the airport (most convenient = most expensive).
Your best choice is to pay as much as possible with credit card; many offer real fee-free conversion. For the cash you absolutely need, ATMs are the least expensive, as said, stick with ATMs inside banks if you have a choice.