An ATM hardly ever makes any mistakes when giving you your cash etc but it is a machine after all and sometimes they can and do make mistakes.
If an ATM does make a mistake in giving you the wrong amount of cash such as too little cash then contact your bank or if possible contact the ATM owner and they will sort it out.
And of course if the ATM gives you too much cash you still need to contact the ATM machine operator or the bank if it's a bank owned ATM and give them the extra cash that was dispensed to you.
The bank will find out about the extra cash because they have cameras on them so they will be contacting you anyway.