You can get hit from both sides: the local ATM operator may add its own surcharge, disclosed on screen before you confirm, and your home bank may charge a foreign ATM fee plus a percentage foreign transaction fee. Independent convenience ATMs in tourist strips are the worst offenders on the local side; bank-operated machines are usually cheaper and in some countries free for foreign cards.
On your side, the fix is choosing the right card before you travel. Many banks and fintechs offer accounts with no foreign transaction fees, and a few even reimburse other banks' ATM surcharges up to a monthly cap; check what your own bank offers or consider opening a travel-friendly account. Failing that, make fewer, larger withdrawals so fixed fees hurt less.
Always read the fee screen, always decline the machine's currency conversion offer, and if one bank's machines charge heavily, simply try another brand down the street; fees genuinely differ between banks in the same city.