It varies widely by bank, ATM owner, location, etc. There is no single correct answer.
For example, in the USA it is not uncommon for a small store or restaurant to contract with a company to place an ATM on the premises for the “convenience” of their customers. In such a case, a fairly normal, but not universal, result is that the company that owns the ATM (not necessarily a bank and not usually the business that it is located inside) will charge a fee to use that ATM. In some cases, the customer’s bank will charge a separate fee for the use of an “out of network” ATM. In that case, both entities charge the customer. And there are variations from that all the way to no charge for the transaction at all, depending on who owns the ATM and which bank the customer does business with - sometimes even in random stores the ATM can be owned by the customer’s home bank.